Hello,
I have a post category called (Anonymous posts) and a user called (anonymous), If any logged in user select the category (Anonymous posts) and publish, then automatically change the logged in author to another author called (anonymous).
This change should only occur upon clicking (publish) and should not occur when post is saved as (draft)
This is an edited example from your code
/** * Update BuddyBlog Author when a post is submitted in a specific category. */ add_filter( 'bblpro_post_submission_prepared_data', function ( $post_data, $cat_id, $post, $is_submission ) { // update author if the category was selected. Don't do anything on edit. if ( $is_submission && 1487 === (int)$cat_id ) { $post_data['post_author'] = 4766806; // keep current user data for future? if ( ! empty( $post_data['ID'] ) ) { update_post_meta( $post_data['ID'], '_bbl_original_post_author', get_current_user_id() ); } } return $post_data; }, 10, 4 );
Hi Tosin,
I will need couple of days to have setup and test your code in order to assist you with it. I will be replying sometimes this week after testing.Regards
BrajeshThat’s what I am referring to. The code you have supplied may not be suitable and I will need to try my update on a local setup.
Hi Tosin,
Sorry, I could not help you earlier.1. Do you want to limit the scope of this update to certain form? If yes, Please share the form id.
2. By category, are you referring to post category or is it a custom taxonomy? If it is a custom taxonomy, Please let me know about the name and label.Regards
BrajeshThank you Tosin,
I will be sharing code soon.Regards
Brajesh
The topic ‘ [Resolved] Buddyblog change author if post is published in a specific category’ is closed to new replies.