Your need is a bit vague. Could you provide more details of what you are looking for and perhaps provide a use case? That would be helpful to know what you are looking for.
I have two form with hidden value(not in form) of roles.
Both are registration form, one used for author another one for subscriber.
When a subscriber register no need to admin approves. But when author register need to send admin approve, then only create an account for this user.
Hello! I’m looking a solution for a similar isssue, I made a form for the sellers registration and I need to approve those users before they can enter the reserved area.
There’s a way to set the approval just for one user role?
@creativibiz,
I used below action in this scenario
do_action( ‘new_user_approve_approve_user’, $user_id );
@creativibiz,
You can use below action in function.php and also you can change what are the roles you want to use.
/*auto approve for user role when users register*/
add_action( ‘user_register’, ‘auto_approve_user’, 10, 1 );
function auto_approve_user( $user_id ) {
//Role based email template
$user_info = get_userdata($user_id);
//get user role
$user_role = $user_info->roles[0];
if($user_role == ‘subscriber’)
{
do_action( ‘new_user_approve_approve_user’, $user_id );
}
}
@gnanasekaran,
With the code you posted copied into the beginning of my functions.php file, new users are not automatically approved. Even when I remove if the if statement surrounding the approve action, users are not approved automatically.
Any ideas on what is causing the issue? Is the approve function not working properly?
-Chris
/* auto approve for user role when users register */
add_action( ‘user_register’, ‘auto_approve_user’, 10, 1 );
function auto_approve_user( $user_id ) {
//Role based email template
$user_info = get_userdata($user_id);
//get user role
$user_role = $user_info->roles[0];
if($user_role==’subscriber’)
{
do_action( ‘new_user_approve_approve_user’, $user_id );
}
}
@andersan,
There is a two reason,
1. your website not calling auto_approve_user when user regiter
2. You could not get $user_id in auto_approve_user() function.
you can manually check with below action,
do_action( ‘new_user_approve_approve_user’, $user_id );