Custom function for “Submit for Review” hook

You need Post Status Transitions actions function notify_me_for_pending( $post ) { $user_info = get_userdata ($post->post_author); $strTo = array (’[email protected]’); $strSubject=”Fstoppers: ” . $user_info->user_nicename . ‘ submitted a post’; $strMessage=””” . $post->post_title . ‘” by ‘ . $user_info->user_nicename . ‘ was submitted a post for review at ‘ . wp_get_shortlink ($post->ID) . ‘&preview=true. Please proof.’; wp_mail( … Read more

Get email address of type Administrator

You can use this function to get email of all the Administrator on a WordPress website function get_administrator_email(){ $blogusers = get_users(‘role=Administrator’); //print_r($blogusers); foreach ($blogusers as $user) { echo $user->user_email; } }

Notify multiple email addresses on comments

Post authors are notified of new comments by default; there are several plugins that modify this behavior. See wp_notify_postauthor. You can hook into comment_notification_recipients and add an aribtrary list of recipients as described here. Then you could create a metabox or dashboard widget to manage the recipient list. Keep in mind that this functionality might … Read more

If new comment posted in custom post – send notification to custom email from custom field

You can try something like this in your functions.php function send_comment_email_notification( $comment_ID, $commentdata ) { $comment = get_comment( $comment_id ); $postid = $comment->comment_post_ID; $master_email = get_post_meta( $postid, ‘master_email’, true); if( isset( $master_email ) && is_email( $master_email ) ) { $message=”New comment on <a href=”” . get_permalink( $postid ) . ‘”>’ . get_the_title( $postid ) . … Read more

Should I use wp_mail or PHP’s mail? [duplicate]

WordPress offers its own mailing system. I suggest you use that instead of PHP’s native mail. wp_mail accepts five arguments: wp_mail( $to, $subject, $message, $headers, $attachments ); So your code can be written this way: // Set the headers $headers[] = ‘From: ‘ . get_option(‘admin_email’); // Add the addresses to an array foreach($emails as $mail) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)