Skip Navigation

[Resolved] Create Two Roles using Cred

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 20 replies, has 4 voices.

Last updated by Christian Cox 7 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#557686

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

#557694

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.

#557893

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...
#558225

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

#558296
Screen Shot 2017-08-09 at 1.51.20 PM.png

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.

#558905

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)

#559330

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.

#559994
notifcation.PNG

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!

#560060

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.

#560437

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?

#560455

Hi I've reset your password - can you enable private messages again - thanks!

#560456

Private reply fields enabled again, thanks!

#560487
Screen Shot 2017-08-16 at 12.12.53 PM.png

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.

#560785
Capture.PNG

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!

#560894

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.