Developer Reference
Constants
| Constant | Value | Description |
|---|---|---|
SWITCHGUARD_PRO_VERSION | 1.0.0 | Pro version |
SWITCHGUARD_PLUGIN_FILE | __FILE__ | Plugin file path |
Filters
| Filter | Arguments | Description |
|---|---|---|
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
| Action | Arguments | Description |
|---|---|---|
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
| Key | Default | Description |
|---|---|---|
retention_days | 30 | Audit log retention |
front_bar_enabled | yes | Show frontend switch bar |
front_bar_color | #2E266D | Bar background colour |
front_bar_message | Viewing as {user} | Bar message template |
front_bar_show_avatar | yes | Show avatar in bar |
floating_button_enabled | yes | Show floating admin button |
floating_button_label | Switch User | Button text |
floating_button_position | bottom-right | Button screen position |
floating_button_color | #2E266D | Button background colour |
admin_redirect_url | '' | Custom post-switch redirect |
require_reauth_privileged | no | Re-auth for privileged targets |
ip_allowlist | [] | Allowed IPs/ranges |
locked_user_ids | [] | Users that cannot be switched to |
idle_timeout_minutes | 0 | Idle auto-switch-back (0 = off) |
scheduled_window_enabled | no | Time-window restriction |
scheduled_window_start | 09:00 | Window start time |
scheduled_window_end | 18:00 | Window end time |
email_notify_enabled | no | Per-switch email alert |
email_notify_address | '' | Alert recipient |
weekly_digest_enabled | no | Weekly digest email |
Audit Log Table
Table: {prefix}switchguard_log
| Column | Type | Description |
|---|---|---|
id | int AUTO_INCREMENT | Log entry ID |
event | varchar | Event type |
switcher_id | int | WordPress user ID of switcher |
target_id | int | WordPress user ID of target |
ip_address | varchar | Switcher's IP address |
user_agent | text | Browser user-agent |
created_at | datetime | Event 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.