This support ticket is created vor 2 Jahren, 8 Monaten. 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.
Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.
I am running into an issue with one of my integrations because Toolset is allowing multiple user roles to be set. Is there a way to disable this feature so that WordPress reverts to its default condition of only allowing users to have one role? Thanks.
The issue is that I am using the wpFusion plugin in conjunction with Active Campaign (our CRM) to synchronize user data. There are certain automations that run in our CRM that may trigger role changes in the website. Active Campaign uses a webhook to send an API call to wpFusion, which then updates the user role. However, it seems to be adding the role instead of replacing the role. Their support has told me it's because Toolset is allowing multiple roles. I wonder if there is a code snippet we can use to remove any existing roles immediately before a new role is applied? Let me know any ideas you may have. Thanks.
Unfortunately I don't have control over what wpFusion does with their code. I just had another idea, though. Can you tell me if there is a Toolset hook that fires when a custom field's value is updated? I could create a custom field called 'wpcf-active-role' that gets updated by wpFusion, and then when that field gets updated I could run a code snippet that sets the actual WordPress role to that same value.
There is a misunderstanding, according to your description above, it seems that the "wpFusion" plugin is using add_role() to setup the user role value, it will conducts the problem, see WP document: https://developer.wordpress.org/reference/classes/wp_user/add_role/
Add role to user.
You need to fix the problem in wpFusion plugin side, it should be able to use set_role() to update user's role, this method will delete user's role value, and update with new user role value
For the new question: Can you tell me if there is a Toolset hook that fires when a custom field's value is updated?