• Resolved kroma

    (@kroma)


    Hello, what can be a reason that for some users I don’t see meta pw_user_status, but for others I see it? I want to show only users which are approved. I query them all with
    $user_query = new WP_User_Query( $args );
    then

    $user_meta = get_user_meta( $user->ID );
    $user_meta['pw_user_status'][0];

    But thing is, some users dont even have
    [pw_user_status]

    Any help on this issue?

    https://wordpress.org/plugins/new-user-approve/

Viewing 1 replies (of 1 total)
  • If a user does not have a status, it is probably because that user registered when the NUA plugin was not activated. They are approved if no status is in the meta table.

    Here is a code snippet from the plugin that you might find helpful:

    if ( $status != 'approved' ) {
         // Query the users table
         $query = array( 'meta_key' => 'pw_user_status', 'meta_value' => $status, );
         $wp_user_search = new WP_User_Query( $query );
    } else {
         // get all approved users and any user without a status
         $query = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'pw_user_status', 'value' => 'approved', 'compare' => '=' ), array( 'key' => 'pw_user_status', 'value' => '', 'compare' => 'NOT EXISTS' ), ), );
         $wp_user_search = new WP_User_Query( $query );
    }
Viewing 1 replies (of 1 total)

The topic ‘Users meta’ is closed to new replies.