• Resolved luxman

    (@luxman)


    What code can I use to check to see if a user has been approved or not?

    a is_user approved or something function?

    thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Michael Beckwith

    (@tw2113)

    The BenchPresser

    You can use this function below, copied from our plugin file.

    Just pass in the user ID you want to check on. It’ll return boolean true if they’re moderated still, and false if they’re not and should have access to things.

    Example:

    if ( bp_registration_get_moderation_status( 1 ) ) {
        // Do something to user 1, since they're moderated right now.
    }
    
    /**
     * Check our moderation status and return boolean values based on that.
     *
     * @since 4.2.0
     *
     * @param int $user_id User ID to check.
     * @return boolean Whether or not they're in moderation status.
     */
    function bp_registration_get_moderation_status( $user_id ) {
    	$moderated = get_user_meta( $user_id, '_bprwg_is_moderated', true );
    
    	if ( 'true' == $moderated ) {
    		return true;
    	}
    	return false;
    }
    
    Thread Starter luxman

    (@luxman)

    Yes, that works perfect! Thank you

    • This reply was modified 6 years ago by luxman.
    Thread Starter luxman

    (@luxman)

    if ( bp_registration_get_moderation_status( 1 ) ) {
        // Do something to user 1, since they're moderated right now.
    }

    This only works for user 1

    How do I make it so that it checks the logged in user?

    something like

    is_user_logged_in() && !bp_registration_get_moderation_status( 'true' )

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    you would need to use something like get_current_user_id() or if you’re trying to display something conditionally based on the BuddyPress displayed user, bp_displayed_user_id(). Both would be used for the first parameter.

    is_user_logged_in() && !bp_registration_get_moderation_status( get_current_user_id() )
    
    Thread Starter luxman

    (@luxman)

    got it. thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP Function or Code to check if user is approved?’ is closed to new replies.