Email Post Attachment on wp_insert_post Action

After asking this question in several places and not getting a solution, I found the solution this morning myself. Instead of hooking the function send_email_on_pending_post_creation to the “wp_insert_post” action, you need to hook it to the “add_attachment” action which occurs AFTER the post is inserted and when the attachment is added to the post. You … Read more

WordPress ajax success response

You can’t use 2 echos for an ajax response. Try this: js: $atj.post(MyAjax.ajaxurl, requestData).done(function(result){ console.log(result); if(result == ‘success’){ $atj(‘.training-form [type=text]’).val(”); $atj(‘.training-form-message’).append(‘<p class=”training-form-complete-message”>Thank you for the email</p>’); } }); php function myajax_submit() { // snip… $mail_check = wp_mail( $to, ‘Email Test’, $message ); remove_filter( ‘wp_mail_content_type’, ‘set_html_content_type’ ); if( $mail_check) echo ‘success’; else echo ‘failure’; exit; }

How to send mail to subscribers using wp_mail

You were on the right track when you built your WP_User_Query, but you are not using the result of this query. See this: //verify post is not a revision if ( !wp_is_post_revision( $post_id ) ) { //gets subscirbers to send email to // WP_User_Query arguments $args = array ( ‘role’ => ‘Subscriber’, ); // The … Read more

Send mail from page using wp_mail

This can (and should) be achieved using the admin_post action. Take a look at the docs for an example: https://codex.wordpress.org/Plugin_API/Action_Reference/admin_post_(action) SitePoint also have a more comprehensive tutorial here: https://www.sitepoint.com/handling-post-requests-the-wordpress-way/ Hope that helps.

Mask Sender Address in wp_mail() in WordPress [closed]

See the documentation: To set the “From:” email address to something other than the WordPress default sender, or to add “Cc:” and/or “Bcc:” recipients, you must use the $headers argument. $headers can be a string or an array, but it may be easiest to use in the array form. To use it, push a string … Read more

Restrict current user from receiving email using wp_mail

Try this: //after $wpdb->insert function $current_user = wp_get_current_user(); $current_mail = $current_user->user_email; //$user_email = $member_details->user_email; if($current_mail !== $_POST[‘user_email’] ){ // send mail only if different from the current_user email $subject = “Congrats! You are added to the Project – ” . “‘” . $project_title . “‘”; $message=”If you are not the member of project plz contact … Read more

How to restrict sending email twice in wp_mail

These POST variables: $_POST[‘user_email’], $_POST[‘user_role’], and $_POST[‘status’] (which each is an array) are connected to each other by their index, hence you can loop through just one of them and use the same index (or iterator) to access the items in the other arrays. This should help you understand it: for ( $i = 0; … Read more

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