There is a front-end form created with acf_form that populates user fields (for example user website, date of birth etc…)
What I need is that when a currently logged in user submits a form from front-end and the data is then saved to user profile (I can manage this without issue with acf_form and correct location rules), that user role changes from subscriber to some other role I’ll create.
Basically once the user submits the form he will immediately get another user role.
You can hook into the acf/pre_save_post filter and then change the user roles using the WP_User class. A user’s role can be set by creating an instance of the WP_user class, and calling the add_role() or remove_role() methods.
The code would look like so:
$u = new WP_User( $user_id );
// Remove role
$u->remove_role( 'subscriber' );
// Add role
$u->add_role( 'editor' );
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users