Hello @ashabazz369,
Thanks for contacting us,
Hope you are doing well, Yes, you can auto-approve the users on a specific role by using this code. Please paste this code into the functions.php file of a child theme.
You should replace any role with a subscriber on the line #8.
Here is the code:
add_action('user_register', 'nua_change_user_status_role_based', 10, 2);
function nua_change_user_status_role_based($user_id, $user_data) {
$userdata = get_userdata( $user_id );
if($userdata) {
$roles = $userdata->roles;
if(in_array("subscriber", $roles)) { // replace the subscriber role with specific one.
update_user_meta( $user_id, 'pw_user_status', 'approved' );
}
}
}
If you have any questions, feel free to reach out. We’re here to assist you.
Thanks & Regards
WP Experts Support Team
-
This reply was modified 2 years, 3 months ago by
Mirza Hamza.