Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I was wondering is there a way to send the admin a notification (email or otherwise) whenever a user submits a post.

Currently, I have to log into the admin section to see if there was anything submitted. I need to review their post before actually publishing it, so I need to be notified via email whenever a post is submitted.

Does anyone know of a solution for this?

Thanks a lot

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You could try this inside your themes functions.php:

its a function by dagon design

function dddn_process($id) {

global $wpdb;

$tp = $wpdb->prefix;

$result = $wpdb->get_row("
    SELECT post_status, post_title, user_login, user_nicename, display_name
    FROM {$tp}posts, {$tp}users
    WHERE {$tp}posts.post_author = {$tp}users.ID
    AND {$tp}posts.ID = '$id'
");

if ($result->post_status == "publish") {

    $message = "";
    $message .= "A new post was submitted on '" . get_bloginfo('name') . "'\n\n";
    $message .= "Title: " . $result->post_title . "\n\n";


    $message .= "Author: " . $result->display_name . "\n\n";

    $message .= "Link: " . get_permalink($id);

    $subject = "Post Submitted on '" . get_bloginfo('name') . "'";

    $recipient = get_bloginfo('admin_email');

    mail($recipient, $subject, $message);

}

}

add_action('publish_post', 'dddn_process');  
share|improve this answer
    
It works! What would I set post_status for published posts instead of pending? –  user1893 Jun 21 '11 at 16:55
    
changing if ($result->post_status == "pending") { to if ($result->post_status == "publish") { should do it.. –  MartinJJ Jun 21 '11 at 16:58
    
Marin, I "publish" but it didn't send the email... –  user1893 Jun 21 '11 at 17:17
    
Have edited my original post with the changes, try that big block of code again, have added a little to it regarding the action hook –  MartinJJ Jun 21 '11 at 17:41
    
OK, thanks I will try this code. –  user1893 Jun 21 '11 at 18:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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