• Resolved amkh

    (@amkh)


    I recently installed this plugin. I would like some of the exiting members that were already registered before installing this plugin to be moderated. How I can I add these users to “moderated”?

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

    (@tw2113)

    The BenchPresser

    Good day @amkh

    I know we have a similar enhancement issue opened over at https://github.com/WebDevStudios/BuddyPress-Registration-Options/issues/117 but nothing has been done with it yet.

    That said, any solution I can offer here is going to be relatively code-based. Is that something you’re comfortable with? or is that something “above your head” ?

    Thread Starter amkh

    (@amkh)

    Thank you for you response.
    A code based solution is fine with me. I can apply it in bp-funtions.php or through snippets plugin.

    Thread Starter amkh

    (@amkh)

    What I am exactly looking for is to add selectively some active members to the non-approved list. These members were registered before installing this plugin. I do not want them to be to access buddypress until they update their profiles.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    You’ll only want to run this once or so, or else it just ends up being excess processing.

    
    function amkh_set_user_statuses() {
    	$user_ids = array( 145, 654, 357, 900, 42 );
    	foreach( $user_ids as $id ) {
    		bp_registration_set_moderation_status( $id, 'true' );
    	}
    }
    add_action( 'admin_head', 'amkh_set_user_statuses' );
    

    The first part would be just an array of user IDs that you want to mark as pending. The foreach loop would iterate over them all, and set the moderation status. Running it on admin_head in my example code because it should only run once. You’ll want to set up your array to match the IDs you want to re-set.

    In case curious about this function:

    function bp_registration_set_moderation_status( $user_id = 0, $status = 'true' ) {
    	$user = get_userdata( $user_id );
    
    	if ( ! $user ) {
    		return false;
    	}
    
    	delete_user_meta( $user_id, '_bprwg_is_moderated' );
    	return update_user_meta( absint( $user_id ), '_bprwg_is_moderated', $status );
    }
    

    We check if a user exists with that ID, and then for all that do, we clear out and re-set our meta key/value pair with the status passed.

    Thread Starter amkh

    (@amkh)

    Thank you very much dear Michael. Your code was perfect. It worked.

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Woohoo!

    Glad we could help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How can I convert some selected and already registered users moderated?’ is closed to new replies.