Solution:
There is an action to hook to inside bp_core_activate_signup()
that fires right after activating the account ( user clicked the link in the email ), so when the user hits /activate
this will fire and reset the user_status to 3
( 1
is spammer I guess ). Now to figure out the rest…
Here is the code ( the second function disallows the user from logging in with custom message ):
add_action( 'bp_core_activated_user', 'custom_bp_core_activated_user' );
function custom_bp_core_activated_user( $user ) {
if ( empty( $user ) ) {
return false;
}
if ( is_array($user) ) {
$user_id = $user['user_id'];
}
else {
$user_id = $user;
}
$member_type = bp_get_member_type($user_id);
if ( $member_type == 'member_type_to_manually_activate' ) {
global $wpdb;
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 3 WHERE ID = %d", $user_id ) );
}
}
add_filter( 'authenticate', 'custom_authenticate', 30 );
function custom_authenticate( $user ) {
if ( is_wp_error( $user ) || empty( $user ) ) {
return $user;
}
if ( 3 == $user->user_status ) {
$member_type_name = bp_get_member_type($user->ID);
$member_type = bp_get_member_type_object($member_type_name);
return new WP_Error( 'invalid_username', __( '<strong>ERROR</strong>: All ' . $member_type->labels['name'] . ' accounts require manual confirmation from an admin. You might be contacted soon to verify your identity. You will recieve an email once your account is approved.', 'buddypress' ) );
}
return $user;
}
Hello! Can you please help me to realize this but with user roles. Thank you!