Hi goelsuryansh,
Your best bet is to use bp_verified_member_verified_status_updated action hook, i currently use that for a different reason but in almost the same way.
This is fired whenever a user’s status is updated from verified to unverified and vice versa.
add_action('bp_verified_member_verified_status_updated', 'goelsuryansh_assign_verified_user_role', 10, 2);
function goelsuryansh_assign_verified_user_role($user_id, $status)
{
$user = new WP_User($user_id);
if ($status == 'verified') {
$user->set_role('verified_user');
} else {
$user->remove_role('verified_user');
}
}
Just double check that you need to use set_role . I’d suggest using caps instead of roles, that would most likely serve you better than roles. check https://developer.www.ads-software.com/plugins/users/roles-and-capabilities/#adding-capabilities
Hope that helps.
Cheers!