settings(); $settings->add_section( 'users', 'user_switching', __( 'Switch to User', 'all-in-one-utilities' ), __( 'Let administrators switch to any user\'s account to see the site as they do, then switch back with one click.', 'all-in-one-utilities' ), 35 ); $settings->add_field( 'users', 'user_switching', new Field( id: 'enabled', label: __( 'Enable user switching', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Add "Switch to" links for administrators', 'all-in-one-utilities' ) ), doc: new Doc( title: __( 'Switch to User', 'all-in-one-utilities' ), short: __( 'Adds a "Switch to" link to each user in Users → All Users and on their profile. Clicking it logs you in as that user; a bar at the bottom of every page lets you switch back.', 'all-in-one-utilities' ), detailed: __( 'Only administrators can switch, and only to users they are allowed to edit. No password is needed or revealed. Your own login is kept safe while you are switched: switching back restores it, and logging out while switched ends both sessions. Switching does not count as the user logging in, so their "Last Login" stays unchanged.', 'all-in-one-utilities' ), warnings: array( __( 'While switched, everything you do is done as that user -- orders, comments and profile changes are saved under their account.', 'all-in-one-utilities' ) ) ), priority: 10 ) ); $settings->add_field( 'users', 'user_switching', new Field( id: 'redirect', label: __( 'After switching, go to', 'all-in-one-utilities' ), type: 'select', default: 'home', args: array( 'choices' => array( 'home' => __( 'The site\'s home page', 'all-in-one-utilities' ), 'admin' => __( 'The user\'s dashboard (wp-admin)', 'all-in-one-utilities' ), ), 'depends_on' => 'enabled', ), doc: new Doc( title: __( 'After switching', 'all-in-one-utilities' ), short: __( 'Where you land once you are logged in as the user. Users who can\'t use wp-admin (e.g. WooCommerce customers) are sent on to their account page by WooCommerce itself.', 'all-in-one-utilities' ) ), priority: 20 ) ); if ( $settings->get_value( 'users', 'user_switching', 'enabled', 0 ) ) { ( new Feature() )->register(); } } }