When using a form to create both a user and post, you may choose to set the new user as the post author. Advanced Forms Pro handles user creation first and appends the newly created user ID to the AF()->submission array under the 'user' key. It is then available for use in subsequent hooks/filters as per the following example:
add_filter( 'af/form/editing/post_data', function ( $post_data, $form, $args ) { if ( $form['key'] === 'FORM_KEY' ) { $post_data['post_author'] = AF()->submission['user']; } return $post_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