On user registration, if welcome mail sent, add post with new user as author

Instead of using wp_mail filter use action user_register: function fpw_new_user_post( $user_id ) { global $wpdb; update_user_meta( $user_id, $wpdb->base_prefix . ‘capabilities’, array( ‘author’ => TRUE ) ); $new_post = array ( ‘post_title’ => ‘User ‘ . get_user_by( ‘id’, $user_id )->user_login . ‘ registered @ ‘ . date( ‘Y-m-d H:i:s’, current_time( ‘timestamp’ ) ), ‘post_content’ => ‘This … Read more

PHP mail() works but wp_mail() does not

The plugin, WP Mail SMTP, looks like a possible solution to use the wp_mail() properly on your localhost. According to the description: Reconfigures the wp_mail() function to use SMTP instead of mail() and creates an options page to manage the settings.

WordPress wp_mail() how to add a .GIF

You have to provide the absolute path for your included image, as the receiver of the email does not have a file “signature.gif” in a folder “img” (that’s where the client is going to search it) Replace $message .= “<img src=”https://wordpress.stackexchange.com/questions/266338/img/signature.gif”>”; with $message .= “<img src=”http://yourwebsite.com/PATH/TO/img/signature.gif”>”; Where yourwebsite.com is your website’s domain followed by the … Read more

Validate emails in array using foreach

Are you aware you can pass a comma-separated string of email adresses to wp_mail? // Make sure your email strings only uses comma as a separator $emails = preg_replace(‘~[,;\s]+~’, ‘,’, $emails); Then just throw that string into wp_mail’s first argument. Depending on exactly what you want to do with the emails, this approach may be … Read more

Trigger WordPress Actions from Email?

You can solve it like this: use wp_schedule_event to check if any user needs to get the mail if yes, send the mail containing a link like yoursite.com/?user_id=99&myaction=yes&mytoken=sometokenforsecurity Save that token to the user´s user_meta add_user_meta( $user_id, ‘mytoken’, $token, true ) In your case you obviously need a second link with action=no or whatever you … Read more

How to send email in wordpress with more than one attachments

Don’t know if that will solve all your problems, but: Generally nicely formatted code is easier to debug. E.g. your code is missing the closing brace. Besides it is better to write if/else(if) statements with braces. Nice indentation helps too. I’d suggest reading the WordPress – PHP Coding Standards. Regarding your code: As noted at … Read more

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