I'm having a difficult time trying to update the flamingo_inbound
post author after insert.
Basically, I have a hidden field in CTF7
for the company name that is being sent over and correctly stored in the db. That field corresponds to a particular company page.
Here's my code so far.
function my_update_flamingo_inbound_author($post){ $post_type = get_post_type($post); $post_id = $post->ID; if($post_type == 'flamingo_inbound') { $company_name = get_post_meta($post_id, '_field_company-name', true); if($company_name) { $company_post = get_page_by_title($company_name, 'OBJECT', 'company'); if($company_post) { $post_author = $company_post->post_author; $post->post_author = $post_author; wp_update_post($post); } } } } add_action( 'new_to_publish', 'my_update_flamingo_inbound_author', 10);