Documentation
SwitchGuard Pro
Developer Reference

Developer Reference


Constants

ConstantValueDescription
SWITCHGUARD_PRO_VERSION1.0.0Pro version
SWITCHGUARD_PLUGIN_FILE__FILE__Plugin file path

Filters

FilterArgumentsDescription
switchguard_pro_can_switch$can (bool), $switcher_id (int), $target_id (int)Override Pro permission check
switchguard_pro_front_bar_message$message (string), $target_user (WP_User)Modify frontend bar message
switchguard_pro_idle_timeout$minutes (int), $target_user (WP_User)Override idle timeout per user
switchguard_pro_in_schedule$in_schedule (bool)Override scheduled window check
switchguard_pro_log_event$event (array)Modify or cancel audit log entry; return false to skip

Actions

ActionArgumentsDescription
switchguard_pro_switch_blocked$reason (string), $switcher_id (int), $target_id (int)Fires when a switch is blocked
switchguard_pro_idle_switched_back$original_user (WP_User)Fires on idle auto-switch-back
switchguard_pro_digest_sent$data (array)Fires after weekly digest email
switchguard_pro_grant_added$user_id (int), $target_id (int)Fires when a grant is added

Pro Settings Defaults

KeyDefaultDescription
retention_days30Audit log retention
front_bar_enabledyesShow frontend switch bar
front_bar_color#2E266DBar background colour
front_bar_messageViewing as {user}Bar message template
front_bar_show_avataryesShow avatar in bar
floating_button_enabledyesShow floating admin button
floating_button_labelSwitch UserButton text
floating_button_positionbottom-rightButton screen position
floating_button_color#2E266DButton background colour
admin_redirect_url''Custom post-switch redirect
require_reauth_privilegednoRe-auth for privileged targets
ip_allowlist[]Allowed IPs/ranges
locked_user_ids[]Users that cannot be switched to
idle_timeout_minutes0Idle auto-switch-back (0 = off)
scheduled_window_enablednoTime-window restriction
scheduled_window_start09:00Window start time
scheduled_window_end18:00Window end time
email_notify_enablednoPer-switch email alert
email_notify_address''Alert recipient
weekly_digest_enablednoWeekly digest email

Audit Log Table

Table: {prefix}switchguard_log

ColumnTypeDescription
idint AUTO_INCREMENTLog entry ID
eventvarcharEvent type
switcher_idintWordPress user ID of switcher
target_idintWordPress user ID of target
ip_addressvarcharSwitcher's IP address
user_agenttextBrowser user-agent
created_atdatetimeEvent timestamp

To cancel an audit log entry programmatically, use the switchguard_pro_log_event filter and return false. This is useful for excluding automated system switches from the log.