• Resolved damtox

    (@damtox)


    Hi,
    I cannot access “account_status”. How to check if the user has confirmed the email or not?

    My code:

    $args = array(
                        'role'          =>  'subscriber',
                        'meta_key'      =>  'account_status',
                        'meta_value'    =>  'approved'
                    );
    
                    $users = get_users($args);
    
                    foreach ($users as $user) {
                        echo '<pre>';
                        print_r( $user );
                        echo '</pre>';
                    }

    I want to check if the user is “approved”. How is it displaying xxx, how is it not displaying yyy?
    Can anyone help?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @damtox

    The code above is working for me.

    Here’s a modified version to test it:

    add_action("init","um_062221_get_approved_users");
    function um_062221_get_approved_users(){
    
        $args = array(
            'role'          =>  'subscriber',
            'meta_key'      =>  'account_status',
            'meta_value'    =>  'approved'
        );
    
        $users = get_users($args);
    
        foreach ($users as $user) {
            echo '<pre>';
            print_r( $user );
            echo '</pre>';
        }
    
        wp_die('test');
    }

    Regards,

    Thread Starter damtox

    (@damtox)

    @champsupertramp – thank you 🙂
    I solved my problem like this:

    $args = array(
                'role'    => 'subscriber',
                'orderby' => 'ID',
                'order'   => 'DESC',
            );
            $blogusers = get_users( $args );
    
            foreach (array_slice($blogusers, 0, 10) as $user) {
                $userid = $user->ID ;
    
    if ($user->account_status == 'approved' ) {
                            echo 'xxx';
                        } else {
                            echo 'yyy';
                        }
    
    }
    • This reply was modified 1 month, 1 week ago by damtox.
    • This reply was modified 1 month, 1 week ago by damtox.
    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @damtox

    Thanks for letting us know how you resolved the issue. I’m marking this as resolved now.

    Regards,

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