I am developing my site and require to change post author id on the fly while publishing.
All post will be write and publish by admin but as content provided by different author and need to change post author id from admin to other author ( author id will get from custom field )
So how to do this on the fly while publishing.
Here is my theme metabox.php code I am using wpalchemy metabox script and below code is in my cpt loop php file
// getting custom field value from image_artist // this is giving value like artist_login_name / id $png_gallery_meta->the_field('image_artist'); $artist_info = $png_gallery_meta->get_the_value(); // to separate artist_login_name and id $string = $artist_info; $artist = substr($string, 0, stripos($string, "/") ); // getting first name and last name from user id $author_first_name = get_userdata(basename($string))->first_name; $author_last_name = get_userdata(basename($string))->last_name;
So I am using above code to get user info from custom field dropdown selection box. Now how can I use above value to change id on the fly while admin publish the post the post author id should change with above id value get from selection box. I hope now it is more clear.