Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

deprekate on "custom field getting over written"

$
0
0

I have the following action in a child functions.php that is correctly hooking right after the administrator hits Publish. It also correctly sets the advanced custom field to '1234'. However I think the default theme then kicks in and sets the 'doi' custom field back to empty.

<?php
function get_doi( $new_status, $old_status, $post ) {
    if ( $new_status == 'publish' && $old_status != 'publish' ) {
        $value = "1234";
        update_field( "doi", $value, $post->ID );
        $field = get_field("doi", $post->ID); //dumped to error_log and is 1234
    }
}
add_action('transition_post_status', 'get_doi', 10, 3 );
?>

Viewing all articles
Browse latest Browse all 8245

Trending Articles