How can I send an email in my plugin?

Use wp_mail(), not just mail(). It is a wrapper for PHPMailer, a class that takes care for many problems the native mail() function often gets. See my plugin 404 Tools for how to use it in this case. To send an HTML email see Milo’s answer to a related question.

Same email for all comments

Just change to to address for these emails. Sample code, not tested: // hook in late, to avoid side effects. add_filter( ‘comment_notification_headers’, ‘wpse_73855__change_comment_notify_to’ ); function wpse_73855__change_comment_notify_to( $input ) { if ( ‘comment_notification_headers’ === current_filter() ) { add_filter( ‘wp_mail’, __FUNCTION__ ); return $input; } $input[‘to’] = get_option( ‘admin_email’ ); remove_filter( current_filter(), __FUNCTION__ ); return $input; }

Receive each week the number of posts published

Here is a basic use for WP_Query that returns an object containing all posts for the current week as $query. The last line echos the property `found_posts’, which provides the count for the week query. $args = array( ‘date_query’ => array( array( ‘year’ => date( ‘Y’ ), ‘week’ => date( ‘W’ ), ), ), ); … Read more

WordPress Registration Email by Role

Scroll down a little bit, most of it is WordPress default code but you must add everything to your plugin or you might break it! I’ve also added few useful snippets below. Copy-paste them to same plugin. <?php /* * Plugin Name: Emails * Plugin URI: http://www.your-site.com * Description: Different registration email for different roles … Read more

Is it possible to change an existing post status from ‘pending’ to ‘publish’ via email?

Step 1 – Register a Custom Query Var By adding a custom query var, you make WP aware of it so it can be used in requests. function wpse_add_query_vars( $vars ) { $vars[] = ‘wpse_set_to_publish’; return $vars; } add_filter( ‘query_vars’, ‘wpse_add_query_vars’ ); Step 2 – Sniff The Request Now we hook into parse_request to look … Read more

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