Support » Plugin: User Switching » add switch link as meta data

  • Resolved oberning

    (@oberning)


    Hi,

    I am wondering whether it is possible to add the switch to a user link as a meta data to the users profile.
    I found the code in the FAQ:

    if ( method_exists( 'user_switching', 'maybe_switch_url' ) ) {
        $url = user_switching::maybe_switch_url( $target_user );
        if ( $url ) {
            printf(
                '<a href="%1$s">Switch to %2$s</a>',
                esc_url( $url ),
                esc_html( $target_user->display_name )
            );
        }
    }

    But I don’t know how to use this and add it as user meta data.
    I hope you can help me out.

    Best,
    Olga

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    This is PHP code. You need to put it inside the relevant PHP template for your theme, usually author.php, and then populate the $target_user variable with the WP_User object for the target user.

    If you’re not sure where this needs to go or how to do it then your best bet is to contact the author of your theme and ask for advice.

    Cheers!

    Thread Starter oberning

    (@oberning)

    Hi @johnbillion,

    thanks a lot!
    I’m going to try that.

    I’m sorry about my many questions, I’m having one more, I will open a new topic for that.

    Best regards,
    Olga

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.