• Hey,

    I’m trying to setup a simple notification to the author when a post is published.
    It works, however, if i try to include any custom fields in the message, i don’t get the meta value for any field, only “1”.


    function email_user($post_ID) {
    global $wpdb, $post;

    $auth = get_post($post_ID);
    $auth_PID = $auth->ID;
    $authid = $auth->post_author;
    $participante_ID = get_post_meta($auth_PID, "nome", true);
    $posttype = $auth->post_type;

    $to = get_the_author_meta('user_email',$authid);

    $headers = 'Example <[email protected]>' . "\r\n" ;
    $message= "
    Hi, ". $participante_ID[0] ."

    Your post is online.

    Edit: https://www.example.com/wp-admin/post.php?post=$post_ID&action=edit
    Preview: https://www.example.com/?p=$post_ID&preview=true \r\n

    Thanks.
    ";

    wp_mail($to, "Post Notification", $message, $headers);
    return $post_ID;
    }

    add_action('publish_participante', 'email_user');

    Am I missing something? Thanks a lot,

  • The topic ‘Email notification on post publish’ is closed to new replies.