Support » Plugin: User Registration - Custom Registration Form, Login And User Profile For WordPress » is there a way to allow the user to select the role?

  • Resolved somlaweb

    (@chefnelone)


    Hello,

    is there a way to allow the user to select the role (Customer, Custom_Role,..) in the registration form?

    thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Rumesh Udash

    (@rumesh38)

    Hi @chefnelone,

    Sorry, but currently it’s not possible to allow the user to select any role. But you can build a different registration form for different roles for a way around.

    Regards!

    Hi, that is a good trick.

    But then, I will need to be able to:

    1- set “Admin Approval after registration” for ‘my customs registration form 1’.

    2- set “Manual Login after Registration” for ‘my customs registration form 2’.

    I don’t see this feature in the free plugin. Can I get this feature with your addons? Let me know.

    Thanks.

    • This reply was modified 2 months, 1 week ago by  somlaweb.

    Hi @chefnelone,

    Here is a way around for that. If you set the User Registration’s setting to Admin Approval. Your issue with form 1 will be solved. Now for form 2, note its form id and then go to the function.php in your active theme’s folder and paste this code:

    
    add_action( 'user_registration_after_register_user_action', 'approve_form', 10, 3 );
    function approve_form( $valid_form_data, $form_id, $user_id ) {
    	if ( 40 == $form_id ) {
    		$user_manager     = new UR_Admin_User_Manager( $user_id );
    		$alert_user_email = true; // Set true to send email to user for approval.
    		$user_manager->save_status( UR_Admin_User_Manager::APPROVED, $alert_user_email );
    	}
    }
    

    In the above code, please replace 40 with the form ID of your form 2. Now the user who gets registered through this form will be automatically approved and they will be able to login manually.

    Regards

    Hello,

    It worked.

    Just a small issue. In the form 2 (in frontend) when the form is submitted this text is shown: “User registered. Wait until admin approves your registration.”

    How can I change this text too?

    • This reply was modified 2 months, 1 week ago by  somlaweb.
    • This reply was modified 2 months, 1 week ago by  somlaweb.
    Plugin Support sharmadpk03

    (@sharmadpk03)

    Hi @chefnelone,

    I am afraid that you cannot change the text as it will change the text for your form 1 too. The best option for the users registering from form 2 will be the auto-login option. Users will be directly logged in after the registration.

    To enable this feature, you have to replace the previous code that we sent with this one

    add_action( 'user_registration_after_register_user_action', 'approve_form', 10, 3 );
    function approve_form( $valid_form_data, $form_id, $user_id ) {
        if ( 40 == $form_id ) {
            $user_manager     = new UR_Admin_User_Manager( $user_id );
            $alert_user_email = true; // Set true to send email to user for approval.
            $user_manager->save_status( UR_Admin_User_Manager::APPROVED, $alert_user_email );
            wp_clear_auth_cookie();
            wp_set_auth_cookie( $user_id );
            $success_params['auto_login'] = true;
    
        }
    }

    Note: Keep in mind to change the form id 40 with the actual form id that your form has.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.