Hey! Thanks for using our plugin.
As it’s a developer focused plugin, I’ll suggest a not-good-practice solution… change the plugin file:
Go to file class-switch-user-frontend.php in line 173 and 175.
The main intent to use user->login is that it is required to exist.
I promise I’ll add a filter someday.
Have a nice weekend.
Thank you I will take a look, have a great weekend too
Hi Mario,
Tried to get the required result but no luck: any ideas how to get billing company name displayed, thank you
echo ‘<li class=”current-user” data-user-id=”‘ . $user->billing_company . ‘” title=”‘ . __(“You are logged as this user”, SWITCH_USER_TEXTDOMAIN) . ‘”>’ . $user->user_login . ‘‘;
} else {
echo ‘<li class=”js-su-user” data-user-id=”‘ . $user->billing_company . ‘” title=”‘ . __(“Click to login as this user”, SWITCH_USER_TEXTDOMAIN) . ‘”>’ . $user->user_login . ‘‘;
You have the $user object, but billing_company is not a user property (a WordPress user field). Perhaps it’s a user meta data created by a plugin.
Try:
get_user_meta($user->ID, 'billing_company', true)
Thanks sorted it
foreach ( $users as $user ) {
$billing_company = get_user_meta( $user->ID, ‘billing_company’, true );
if ($user->ID == $current_user_id ) {
echo ‘<li class=”current-user” data-user-id=”‘ . $user->ID . ‘” title=”‘ . __(“You are logged as this user”, SWITCH_USER_TEXTDOMAIN) . ‘”>’ . $billing_company . ‘‘;
} else {
echo ‘<li class=”js-su-user” data-user-id=”‘ . $user->ID . ‘” title=”‘ . __(“Click to login as this user”, SWITCH_USER_TEXTDOMAIN) . ‘”>’ . $billing_company . ‘‘;
}
}
One other item, is it possible to add to child theme, thank you
One other item, is it possible to add to child theme, thank you
I never tried, but the plugin should not make difference from theme or child theme. Maybe your child theme do not implement wp_footer function or it’s incompatible.