If you need to change the user role of the logged in user creating a post, you may use the af/form/editing/post_created hook to run some custom logic as per the following example:
add_action( 'af/form/editing/post_created', function ( $post, $form, $args ) { // If we need to run this only on a specific form, check for the form key. // if ( $form['key'] !== 'YOUR_FORM_KEY_HERE' ) { // return; // } // …add any conditions or logic you need here to safeguard against unwanted user modifications… // Change the role of the post author wp_update_user( [ 'ID' => $post->post_author, 'role' => 'editor' ] ); }, 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