Viewing 8 replies - 1 through 8 (of 8 total)
  • 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.

    Thread Starter Gnanasekaran Loganathan

    (@gnanasekaran)

    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?

    Thread Starter Gnanasekaran Loganathan

    (@gnanasekaran)

    @creativibiz,
    I used below action in this scenario

    do_action( ‘new_user_approve_approve_user’, $user_id );

    Thread Starter Gnanasekaran Loganathan

    (@gnanasekaran)

    @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 );
    }
    }

    Thread Starter Gnanasekaran Loganathan

    (@gnanasekaran)

    @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 );

    Stop-sending-me-emails

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Role based approval’ is closed to new replies.