$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>custom post types - publish_post action callback not executed, why?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

custom post types - publish_post action callback not executed, why?

matteradmin13PV0评论

I create a custom post type and I insert programmatically a new post of that type with wp_insert_post with draft status.

I need to send and email when in backend the post is published so I used publish_post but seems the callback function is not executed, can help me please?

    function post_published_notification( $ID, $post ) {
    /* code for testing purpose only */

    $postarr = array(
            'post_content' => 'fake content ' . $post_id,
            'post_title' => 'fake title ' . $post_id,
            'post_type' => 'gdpr_qao',
        );

    wp_insert_post( $postarr );
}
add_action( 'publish_post ', $plugin_admin, 'post_published_notification', 10, 2 );
Post a comment

comment list (0)

  1. No comments so far