$12
Add custom post type support to this function
function email_author_about_publishing() {
global $wpdb, $post_ID;
$users = $wpdb->get_results( "SELECT ID FROM $wpdb->usermeta WHERE meta_key = 'wp_user_level' && meta_value > 0" );
$post = $wpdb->get_row( "SELECT post_author, post_title FROM $wpdb->posts WHERE ID = " . $post_ID );
$authordata = get_userdata( $post->post_author );
$blogname = get_settings( "blogname" );
$subject = "Your post has been published!";
$text ="Ciao ". $authordata->user_nicename . ",";
$text = $text . "\n\nYour post " . $post->post_title." has been published.";
$text = $text . "\n\nYou can read it here: " . get_permalink( $post_ID );
mail( $authordata->user_email,
$subject,
$text,
"From: " . $blogname . " <" . get_settings( "admin_email" ) . ">" );
}
add_action('publish_post', 'email_author_about_publishing');Thanks for your answers!
Jeremy Phillips | 09/08/11 at 8:57pm
| Edit
(4) Possible Answers Submitted...
-

Last edited:
09/08/11
11:52pm -

Last edited:
09/08/11
9:02pmPippin Williamson says:You have to use a couple more add_action hooks:
add_action('publish_post', 'email_author_about_publishing');
add_action('publish_custom_post_type_name', 'email_author_about_publishing');
Replace "custom_post_type_name" with the name of your post type.- 09/08/11 10:43pm
Jeremy Phillips says:Thanks, that did it! Sorry John, looks like you where beat by a minute!
- 09/08/11 10:43pm
-

Last edited:
09/08/11
9:03pmJohn Cotton says:You need to add more actions....
add_action('publish_type1', 'email_author_about_publishing');Previous versions of this answer: 09/08/11 at 9:03pm
-

Last edited:
09/08/11
9:03pmMaor Barazany says:It appears that the function should work for each post or type, since it fetches the post ID, and not limiting by post_type.
Maybe try to replace the line at the top -
global $wpdb, $post_ID;
with this -
global $wpdb, $post;
$post_ID = $post->ID;
This question has expired.
Jeremy Phillips voted on this question.
Current status of this question: Completed



