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);

            $company_post = get_page_by_title($company_name, 'OBJECT', 'company');
                $post_author = $company_post->post_author;      
                $post->post_author = $post_author;

add_action( 'new_to_publish',  'my_update_flamingo_inbound_author', 10);
  • have you verify that this hook is fired when you need it ?
    – mmm
    Commented Dec 4, 2017 at 8:30

2 Answers 2


You can use the post type within the action name and you gain the removing of an unnecessary check of the post type.

More on this wp_transition_post_status

For instance: When publishing a post for the first time, the post status may transition from ‘draft’ – or some other status – to ‘publish’. However, if a post is already published and is simply being updated, the "old" and "new" statuses may both be ‘publish’ before and after the transition.

add_action( 'publish_flamingo_inbound', 'my_update_flamingo_inbound_author', 10);

And removing the check for post type:

if($post_type == 'flamingo_inbound') {


The flamingo plugin was adding the post and adding the meta data after. I was trying to access the meta data before it was inserted. I decided to use the added_post_meta and updated_post_meta actions instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.