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
1 Answer
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');