get_post_meta returning no value in custom post type alert email

I am working on a function that will alert a user via email when a custom post type (glossary_post) has been created on

I am working on a function that will alert a user via email when a custom post type (glossary_post) has been created on the frontend of my site. It is working well except I need to get the value of a CPT (glossary_tag) to print out in the message of the email and it is returning nothing. My code:

Edited I got this working with the below code but am not sure if it is the correct way to do it.

add_action( 'transition_post_status', 'pending_post_status', 10, 3 );

function pending_post_status( $new_status, $old_status, $post ) {

  $author_id=$post->post_author;
  $address = get_the_author_meta('user_login', $author_id);
  $user_id = get_current_user_id(); 
  $user_info = get_userdata($user_id);
  $edit_author = $user_info->user_login;
  $term_list = strip_tags( get_the_term_list( $post->ID, 'glossary_tag', '', '& ' ));

if ( ( $new_status === "pending" ) && ( $post->post_type == 'glossary_post' ) ){

  $post_title = $post->post_title; 
  $to = 'XXXXXX';
  $subject = 'A Glossary term has been created'; 
  $message = 'A new Glossary term named "' . $post_title . '" has been created in the category "' . $term_list . '" by ' . $address . '. Please login at XXXXX to review and then publish if acceptable.';

  wp_mail( $to, $subject, $message ); 
  }

}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745236729a4617937.html

相关推荐

  • get_post_meta returning no value in custom post type alert email

    I am working on a function that will alert a user via email when a custom post type (glossary_post) has been created on

    7小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信