Logged in users and profile update - user role

By: Dedi Thorne | Asked: 08/19/2024
ForumsCategory: General questionsLogged in users and profile update - user role
Dedi Thorne asked 1 month ago
I may be misunderstanding the documentation on the "Register User" action.  What I understand is that it will change a users role to whatever the action is set to.   For example: I have users added to a role, "Applicants" upon registration (base WooCommerce Customer role). Once the Applicant has taken their 3rd party, proctored exam and passed, their role will be changed to their certification status (base WordPress Contributor role). My update form is available to both roles, so I have it set to the lower role, Applicant (has just Customer capabilities). If a person with contributor's capabilities updates their info on the registration form is it going to change their role to the less functional Applicant again? To me, I would think it would do a role comparison and not change someone unless their role is lower than the role I have it set to.   Role Flow: Person registers - automatically becomes Applicant (Customer). Person passes exam - role is updated to CERTIFIED (Contributor) through backend hooks triggered by the certification expiration being updated. If a CERTIFIED person updates their profile is that form going to set them back to Applicant?   I hope this makes sense.   Thanks! Dedi  
2 Answers
Victor Font answered 1 month ago
Formidable does not do anything about comparing custom roles and knowing what's higher or lower valued. What could work for you is using a field on the registration form to display the possible roles and using that value for updating the WordPress User Role when an entry is created or edited. You can make the role change field only visible to admins.
Dedi Thorne replied 1 month ago

That sounds like it would take a lot of manual watching to see that no one lost their ability to get to their role-specific forms. I think it will be simpler for me to just duplicate the update forms and set the duplicate to be the user role specific to them. I Think I can add both forms to the same page and just have the correct form show, according to user role? W have quite a few forms as there are different aspects of their professional development and we wanted to make each form very specific.

Dedi Thorne replied 4 weeks ago

I this I did what you described automatically with this: https://formidableforms.com/knowledgebase/user-registration/#kb-set-the-user-role

Rob LeVineRob LeVine answered 1 month ago
To add to Victor's answer, you'll want to use frm_after_create_entry and frm_after_update_entry to change the roles
Dedi Thorne replied 1 month ago

I'm about to send an email to you concerning this and one other thing, Rob. Please keep an eye out in case it goes to spam. Subject has my name and that it's from here.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right