0

Im trying to enrich this notification with subject (post title) and content, rather than its current view and edit links, could anyone help?

<?php

function __notify_admin_on_publish( $new_status, $old_status, $ticket )
{
if ( $new_status != 'publish' || $old_status == 'publish' )
    return;

$message = 'View it: ' . get_permalink( $ticket->ID ) . "\nEdit it: " . get_edit_post_link( $ticket->ID );
if ( $post_type = get_post_type_object( $ticket->post_type ) )
    wp_mail( get_option( 'admin_email' ), 'New ' . $post_type->labels->singular_name, $message );

}
add_action( 'transition_post_status', '__notify_admin_on_publish', 10, 3 );
?>
  • What doesn't work exactly? – s_ha_dum Jan 1 '14 at 15:35
  • Nothink, It works fine. It sends an email but with just two links one for viewing the post and the other to edit. I want somethink more content enriched – SoupOfStars Jan 1 '14 at 15:37
0

$ticket is a WP_Post object. It should have all of the information you need. Just add that information to the $message string to create whatever content you want. Bare-bones example:

$message = 'You are viewing '.$ticket->post_title;
$message .= 'Post Content: '.$ticket->post_content;
$message .= 'View it: ' . get_permalink( $ticket->ID ) . "\nEdit it: " . get_edit_post_link( $ticket->ID );

If that isn't what you are looking for, I am certain I don't understand the question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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