• Resolved Anonymous User 15521305

    (@anonymized-15521305)


    Very active support, can I have a question? Is it possible to have user select field in front end so that switching user can be done with the select field in the frontend?

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

    (@johnbillion)

    WordPress Core Developer

    Yep! Take a look in the FAQ, there’s a couple of add-on plugins listed there.

    Thread Starter Anonymous User 15521305

    (@anonymized-15521305)

    With this code

    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 )
            );
        }
    }

    How to use with get_user something like this?

    <?php
    
    $users = get_users();
    
    if ($users) { ?>
        <select name="my_dropdown">
            <?php foreach ($users as $user) {
                echo '<option value="' .$user->ID .'">' .$user->display_name .'</option>';
            } ?>
        </select>
        <?php
    }
    ;?>

    From here https://wordpress.stackexchange.com/questions/113566/how-to-get-a-value-from-wp-dropdown-user

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘User select field in front end’ is closed to new replies.