Hi Christian - sorry for the delay in getting back to you. I'd like to continue working on this ticket please - https://toolset.com/forums/topic/create-two-roles/
I have added the code that you suggested to the code snippets plugin (which replicates adding this to functions.php)
I then used the front end registration form and filled it in selecting the business option. I did the same again but using the personal option.
What I would expect to happen is for the first test (where i filled out the registration form and selected Business) a role is created for the user which has the role Business assigned to it. For the second test (where i filled out the registration form and selected Personal) a role is created for the user which has the role Personal assigned to it
What actually happened is that both users were assigned the role pending
Would you be able to have a look at what I am doing wrong!!! Much appreciated. The login details are the same as for the previous ticket
I have assigned your ticket to Christian as per your request.
He will be around in a few hours from now.
Thanks for the patience.
Hi, in the other ticket I made a change to your generic select field. The field name, "User", was a bit ambiguous so I changed it to something more specific:
[cred_generic_field field='user_select_role' type='select' class='' urlparam='']
My recommendation is to change your CRED form to use the code above to place your generic field, because I used this field name in the PHP code.
If you want to use the field name "User" instead of "user_select_role" that's fine, but you must also modify the PHP code to work with "User" (see the $role variable definition):
...other code...
$role = $_REQUEST['User'];
...other code...
That's brilliant - thank you!
One last step...
I want to send an email notification with the account details password etc to the user when their account is created. I know how to do this, but my question is, is it possible to send different notifications i.e - using the set up that we have created....
IF a user registers as a Business Account they get notification email A
IF a user registers as a Personal Account they get notification email B
Thanks again
Sure, in the email notification editor, look in the section "When to send this notification" and click the button "Add condition by field". You can set a condition based on the selection in your generic field. Create two email notifications for the same form, and send one if the "customer" role is selected, and send the other if the "personal" role is selected.
Hi Christian
I created a new notification alert. Then i selected to send this notification when custom fields are modified. However user_select_role was not available from the additional field conditions select (see screenshot)
Okay this might happen if your generic field isn't set to persist, meaning that it does not get saved in the database. You should add that option to your generic field like this:
[php]
[cred_generic_field field='user_select_role' type='select' class='' urlparam='']
{
"required":0,
"validate_format":0,
"default":[],
"persist":1,
"options":[
{"value":"customer","label":"Business"},
{"value":"personal","label":"Personal"}
]
}
[/cred_generic_field]
Then, you may need to submit the form at least once to register the generic field in at least one User. At that point, the user_select_role field should begin to appear in the list of options.
Hi Christian,
So i added "persist":1, to the generic form and the user_select_role option is now available but the notification i have created (which is supposed to send to the user who is filling in the form) is not sending
Thanks!
My login to your site no longer works, and I'm no longer able to see the register form here:
/phoenix/register/
What am I missing? Private reply fields are enabled if you want to send new credentials.
Hi, I edited my previous comment as requested, but I'm not able to log in using the new credentials. I've tried a couple of different browsers but the form at /phoenix/my-account will not let me in. Can you take a look?
Hi I've reset your password - can you enable private messages again - thanks!
Private reply fields enabled again, thanks!
Okay the trigger for this notification is set to "When custom fields are changed", but the form doesn't edit a User. So the fields don't technically "change". Instead, you should choose "When a new user is created by this form." You can keep the field condition underneath.
Hi Chrisitan,
I have tried that but the notification still doesn't send. See screenshot (if you need to login your account is still active)
Thanks!
but the notification i have created (which is supposed to send to the user who is filling in the form) is not sending
Let me make sure I understand you. You want to send an email to the current, logged-in User, not the User being created by the form. Is that accurate?
If so, your mail notification settings are incorrect, because the "to:" address is coming from the email address typed in the form field. You want the email address of the current User, which will require an additional generic field in your CRED form that captures the current User's ID. Then you can use the setting "Send notification to a WordPress user specified in a form field:".
If I've misunderstood you and the mail notification should go to the new User, then please let me know and I will investigate further. Let me know if it's okay for me to register with some dummy data for testing purposes.