• winmoreuk

    (@winmoreuk)


    Hello, I am hoping you could help me with the following scenario please.

    I want some users to register as Advisors (role) on the website by following the steps below:
    1. use a simple Registration Form to register, auto approved to become role A
    2. once registered, complete their profile information using the Profile Form; once completed, click a button to apply for admin review to become role B

    How do I make this happen? I tried to use two registration forms, assign the 1st to role A and the 2nd to role B. But I cannot use registration form for role B within role A’s page, as the person is already registered.

    Alternatively I want to use a button to trigger an admin review request to approve role B, but how do I build this link?

    This has puzzled me for a long time so I really appreciate some help. Thanks!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Mike

    (@bigmikey00)

    This is actually quite simple.

    So two things
    1. Make sure you have another user role setup for both the Role A and Role B
    2. You need a user Meta key stored to check after the profile has been submitted.

    You can use the profile completeness extension as an option.
    I think this adds a meta field to the profile which you then can call to see if its completed than move the user to the other role.

    The code below is just a sample and would need to be corrected to work but this gives the general idea of what is required.

    This code would need to hook into the function that is called after the submit is hit on profile page. I would have to look through the source to find that hook as i dont have them in front of me at the moment. Let me know if this helps in anyway.

    $user = wp_get_current_user();
     $user_info = get_userdata(); 
     $user_role = $user_info->get_role();
      if ( $user_role == 'um_role_a' ) {
          // here you would check the user's meta data to get the completeness
             $user_id = $user->ID;
             $key = 'key_here';
             $single = true;
             $pcomp = get_user_meta( $user_id, $key, $single ); 
               if($pcomp == 'complete'){
                  // change the role 
                      $user_info->set_role('um_role_b');
                    }
        }
    
    • This reply was modified 6 years ago by Mike.
    • This reply was modified 6 years ago by Mike.
    • This reply was modified 6 years ago by Mike.
    Mike

    (@bigmikey00)

    Now thats an automated method. The other option is at the point where you change the role. Have it send an email, or you can build a table on the admin side that will display the users in that role and have an option to approve or deny. which would either set them back role a or move to role b.

    Let me know if you need help with this further i can set you up with some decent options i just need a few to look over UM’s source again as i forgot most of how they do things.

    Thread Starter winmoreuk

    (@winmoreuk)

    Hi @bigmikey00 , many thanks for your suggestions, sounds good. I should have said I am not a programmer so can only deal with very basic html/shortcode.

    On the admin side of UM the function is already there to see users with pending reviews, from where I can approve/disapprove. So that end is sorted as long as I can build a link between the user profile page and the admin end as you suggested.

    The problem for me is how to link an action from the user profile page (click on a button to apply for role change) to the admin end. Thanks very much for your help.

    Mike

    (@bigmikey00)

    oh that
    So first you would place a button for them to click on I think the form buidler will let you create that if not if someone else can help in the meantime on how to add a button to the profile page. I know you can add it to a custom tab im not sure about the default ones though.

    Either way then you would pass the code below after the form has been submitted.

    $user = wp_get_current_user();
     $user_info = get_userdata(); 
     um_fetch_user($user_info->ID );
     $ultimatemember->user->pending(); // you may have to use global $ultimatemember;
    

    when you look at this you will see them pending and you can set the role from there on the admin side.

    • This reply was modified 6 years ago by Mike.
    • This reply was modified 6 years ago by Mike.
    Thread Starter winmoreuk

    (@winmoreuk)

    I will try it, thanks very much!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to move user from one role to another’ is closed to new replies.