Documentation
SwitchUser Pro
Developer Reference

WindCodex SwitchUser Pro Developer Reference

SwitchUser Pro uses the same actions and base settings as the free plugin - see the free Developer Reference.


Constants

ConstantValueDescription
SWITCHUSER_PRO_VERSIONe.g. '1.0.0'Current Pro version
SWITCHUSER_PRO_DB_VERSIONe.g. '1.0.1'Audit log table version
SWITCHUSER_PRO_PLUGIN_FILE__FILE__Plugin file path
SWITCHUSER_PRO_PLUGIN_DIRplugin_dir_path()Plugin directory
SWITCHUSER_PRO_PLUGIN_URLplugin_dir_url()Plugin URL
SWITCHUSER_PRO_PLUGIN_BASEplugin_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

ActionArgumentsDescription
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

HookScheduleDescription
switchuser_daily_cleanupDailyDeletes audit entries older than the retention period
switchuser_weekly_digestWeeklySends the weekly digest (if enabled)

Pro Settings

Stored in switchuser_settings alongside the free keys:

KeyDefaultDescription
retention_days30Audit log retention (1–3650)
front_bar_enabledyesFront-end bar
front_bar_color#2E266DBar colour
front_bar_messageViewing as {user}Bar message ({user} = display name)
front_bar_show_avataryesAvatar in the bar
front_quick_search_enablednoUser search in the bar
floating_button_enabledyesFloating Switch Back button
floating_button_labelSwitch BackButton text
floating_button_positionbottom-rightbottom-right, bottom-left, top-right, top-left
floating_button_color#6347EBButton colour
admin_redirect_url''Redirect after switching
require_reauth_privilegednoRe-authentication for privileged targets
ip_allowlist''IPs or CIDR ranges, comma or newline separated
locked_user_ids''Comma-separated user IDs
idle_timeout_minutes0Idle auto switch-back (0 = off)
scheduled_window_enablednoTime-window restriction
scheduled_window_start / scheduled_window_end00:00 / 23:59Window times (site timezone)
email_notify_enablednoEmail per switch
email_notify_addressSite admin emailNotification address
weekly_digest_enablednoWeekly digest

User meta

Meta keyDescription
switchuser_allowed_actor_idsWho can switch into this user (comma-separated IDs)
switchuser_allowed_target_idsWhich users this user can switch into (comma-separated IDs)

Audit Log Table

Table: {prefix}switchuser_log

ColumnTypeDescription
idbigintLog entry ID
session_keyvarchar(64)Groups all events of one switch session
event_typevarchar(32)switch_to, switch_back, page_visit, wc_add_to_cart, wc_order_placed
actor_idbigintUser who started the switch
origin_idbigintOriginal account
target_idbigintSwitched-into account
request_urltextPage URL (page visits and WooCommerce events)
ip_addressvarchar(100)IP address
user_agentvarchar(255)Browser user agent
created_atdatetimeTime (UTC)

To add your own events, call SwitchUser_Pro_Log::instance()->insert_event( array( 'event_type' => 'my_event', 'actor_id' => …, 'target_id' => … ) ).