• Resolved cevans247

    (@cevans247)


    With the switch user plugin is it possible to display and link by display name or company name to identify the user quickly

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mário Valney

    (@mariovalney)

    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.

    Thread Starter cevans247

    (@cevans247)

    Thank you I will take a look, have a great weekend too

    Thread Starter cevans247

    (@cevans247)

    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 . ‘‘;

    Plugin Author Mário Valney

    (@mariovalney)

    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)

    Thread Starter cevans247

    (@cevans247)

    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 . ‘‘;
    }
    }

    Thread Starter cevans247

    (@cevans247)

    One other item, is it possible to add to child theme, thank you

    Plugin Author Mário Valney

    (@mariovalney)

    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.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Switch User’ is closed to new replies.