You may modify user data using the af/form/editing/user_data filter. To conditionally modify a user role based on a submitted value, use the af_get_field() function within the hooked callback as per the following example:
add_filter( 'af/form/editing/user_data', function ( $user_data, $form, $args ) { // If we aren't handling the desired form, return early. if ( $form['key'] !== 'FORM_KEY_HERE' ) { return $user_data; } // If a submitted value matches a condition, modify the user role. if ( af_get_field( 'some_submitted_field' ) === 'some value' ) { $user_data['role'] = 'author'; } return $user_data; }, 10, 3 );
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article