By default formidable user registration is set to a subscriber and the other roles can be set manually using the Form settings page, what about if you want to give a registration form user the options of selecting the role to be assigned based on different users without having to create the same registration forms over and over again.
Here will involve a little custom code to be added to your wordpress theme’s function or any child plug-in in your installations that will not require custom update.
the code presented below is already enough to get that done.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//===================creating a different role for users========================================= add_filter('frmreg_new_role', 'frmreg_new_role', 10, 2); function frmreg_new_role($role, $atts){ extract($atts); if($form->id == 9){ //replace 9 with the ID of your forms if($_POST['item_meta'][89] == 'Administrator') //change 89 to the ID of your field and 'Administrator' to the value of your radio button $role = 'administrator'; //////////////////////////////////// else if another one else if($_POST['item_meta'][89] == 'Member') //change 89 to the ID of your field and 'Member' to the value of your radio button $role = 'editor'; //////////////////////////////////// else if another one else if($_POST['item_meta'][89] == 'User') //change 89 to the ID of your field and 'User' to the value of your radio button $role = 'subscriber'; //////////////////////////////////// else if another one } return $role; } |
So easy ? then lets look at the live usage and implementation of the php codes above in the video below
[youtube]https://www.youtube.com/watch?v=sXZumq2rRKw[/youtube]
Berra
Hi
I did exactly as you did in your video, but I did not get it to work!
I get new registered users in Formidable as entries, but user role does not change in WP!
what have I missed?
Thanks in advance for your reply
Edcartech
Hello Berra.
Sorry that did not work for you. certainly you are missing something important to do. if you still have peoblem with htis kindly post your code and give me some details about your registration form and i will help you out.
Thank you