• Resolved todd402

    (@todd402)


    I’m trying to populate a dropdown list with members. I’ve created a code snippet that populates the list successfully with user roles using:

    function getUsers( ) { 
    
    	$roles = array();
    $role_keys = get_option( 'um_roles', array() );
    
    return $role_keys;
    }
    
    ?>

    and that shows:

    How can I populate the dropdown with a list of full-members?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • @todd402

    You can try this code snippet get_all_approved_users as callback.
    I tried with $user->ID as the index but lost the sorting as UM JavaScript made the array user ID sorted.

    function get_all_approved_users() {
        
        $args = array(  'fields'     => array( 'ID', 'user_login' ), 
                        'orderby'    => 'user_login', 
                        'meta_query' => array( 'relation'  => 'AND', 
                                                array(  'key'     => 'account_status',
                                                        'value'   => 'approved',
                                                        'compare' => '=' )), 
                      );
    
        $users = get_users( $args );
        $all_users = array();
        foreach( $users as $user ) {
            $all_users[$user->user_login] = $user->user_login;
        }
        return $all_users;
    }
    Thread Starter todd402

    (@todd402)

    @missveronicatv That worked, thanks for your reply ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Populate dropdown list with members’ is closed to new replies.