WindCodex SwitchUser Pro Developer Reference
SwitchUser Pro uses the same actions and base settings as the free plugin - see the free Developer Reference.
Constants
| Constant | Value | Description |
|---|---|---|
SWITCHUSER_PRO_VERSION | e.g. '1.0.0' | Current Pro version |
SWITCHUSER_PRO_DB_VERSION | e.g. '1.0.1' | Audit log table version |
SWITCHUSER_PRO_PLUGIN_FILE | __FILE__ | Plugin file path |
SWITCHUSER_PRO_PLUGIN_DIR | plugin_dir_path() | Plugin directory |
SWITCHUSER_PRO_PLUGIN_URL | plugin_dir_url() | Plugin URL |
SWITCHUSER_PRO_PLUGIN_BASE | plugin_basename() | windcodex-switchuser-pro/windcodex-switchuser-pro.php |
SWITCHUSER_PRO_LICENSE_OPTION | 'switchuser_pro_license_key' | License key option |
SWITCHUSER_PRO_LICENSE_STATUS_OPTION | 'switchuser_pro_license_status' | License status option |
Actions
| Action | Arguments | Description |
|---|---|---|
switchuser_switched | $data (array) | After switching into a user - actor_id, origin_id, target_id, ip, time |
switchuser_switched_back | $data (array) | After switching back - actor_id, origin_id, from_id, ip, time |
There are no Pro-specific filters or actions.
Scheduled events
| Hook | Schedule | Description |
|---|---|---|
switchuser_daily_cleanup | Daily | Deletes audit entries older than the retention period |
switchuser_weekly_digest | Weekly | Sends the weekly digest (if enabled) |
Pro Settings
Stored in switchuser_settings alongside the free keys:
| Key | Default | Description |
|---|---|---|
retention_days | 30 | Audit log retention (1–3650) |
front_bar_enabled | yes | Front-end bar |
front_bar_color | #2E266D | Bar colour |
front_bar_message | Viewing as {user} | Bar message ({user} = display name) |
front_bar_show_avatar | yes | Avatar in the bar |
front_quick_search_enabled | no | User search in the bar |
floating_button_enabled | yes | Floating Switch Back button |
floating_button_label | Switch Back | Button text |
floating_button_position | bottom-right | bottom-right, bottom-left, top-right, top-left |
floating_button_color | #6347EB | Button colour |
admin_redirect_url | '' | Redirect after switching |
require_reauth_privileged | no | Re-authentication for privileged targets |
ip_allowlist | '' | IPs or CIDR ranges, comma or newline separated |
locked_user_ids | '' | Comma-separated user IDs |
idle_timeout_minutes | 0 | Idle auto switch-back (0 = off) |
scheduled_window_enabled | no | Time-window restriction |
scheduled_window_start / scheduled_window_end | 00:00 / 23:59 | Window times (site timezone) |
email_notify_enabled | no | Email per switch |
email_notify_address | Site admin email | Notification address |
weekly_digest_enabled | no | Weekly digest |
User meta
| Meta key | Description |
|---|---|
switchuser_allowed_actor_ids | Who can switch into this user (comma-separated IDs) |
switchuser_allowed_target_ids | Which users this user can switch into (comma-separated IDs) |
Audit Log Table
Table: {prefix}switchuser_log
| Column | Type | Description |
|---|---|---|
id | bigint | Log entry ID |
session_key | varchar(64) | Groups all events of one switch session |
event_type | varchar(32) | switch_to, switch_back, page_visit, wc_add_to_cart, wc_order_placed |
actor_id | bigint | User who started the switch |
origin_id | bigint | Original account |
target_id | bigint | Switched-into account |
request_url | text | Page URL (page visits and WooCommerce events) |
ip_address | varchar(100) | IP address |
user_agent | varchar(255) | Browser user agent |
created_at | datetime | Time (UTC) |
To add your own events, call SwitchUser_Pro_Log::instance()->insert_event( array( 'event_type' => 'my_event', 'actor_id' => …, 'target_id' => … ) ).