Tell us what you are trying to do?
I use Ultimate Membership Pro (UMP) to manage the membership. In UMP I have created 5 membership levels, where one of this is Free and the others are under payments.
So, in the UMP settings, I have setted that when a new user is registered, the system need to add to every new users the Free Level in both of the role "Stato Base". But the level is not assigned to new users. This I think because I use the Toolset Form for the users registration, and not the native UMP registration form.
There is a way to assign the Free Level to every new user with the role "Stato Base"?
Is there any documentation that you are following? No
You are correct in that the user role is set by what is assigned in your Toolset Forms.
Is this a role an additional role that is set by your Membership plugin ? Or is it that you want to create your user with the role Stato Base the moment they register?
So, in Access I have setted the two Custom Role "Stato Base" and "Stato VIP".
In UMP I have created 5 payment levels (see the attached image) where one of this is free.
UMP permit to assign a specific Role to every levels.
In my case I have 5 payment levels and 2 Custom Role. One payment level is Free and I need to be assigned automatically to every new users same as the Custom Role "Stato Base". When a user want to buy a level it go the dedicated page where there are the list of all payment level (managed by UMP) and he can choose what he need. In the buying moment UMP assign to user the payment level and the Custom Role "Stato VIP". After, when the level expires or user want to cancel the level subscription, UMP assign to user the Free level and the Custom Role "Stato Base".
Using the Register User generated by Toolset Form, the Free level is not automatically assigned to new users. Using the UMP registration form it work, but I want to use Toolset Form.
Thanks for the clarity. I believe I understand a bit more.
Try using this code below.
add_action('cred_save_data', 'my_update_user_role',10,2);
function my_update_user_role($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==12)
{
$user = new WP_User($post_id);
$user->add_role('Stato Base');
}
}
Add this to your custom code in views by going to Toolset -> Settings -> Custom Code and click Add New.
Then add this custom code, then activate it.
Now you need to change the 12 to the ID of your Toolset form that you are using.