How can I get users email (and additional data) from the rest API?

To add the user’s email address in the REST API response, register an additional field to the user object and add the email address: register_rest_field( ‘user’, ‘user_email’, [ ‘get_callback’ => static function (array $user): string { return get_userdata($user[‘id’])->user_email; }, ] ); Please note, however, that this is strongly discouraged because anyone can then see the … Read more

Customizing lost password email

You want the filters… retrieve_password_message for the actual email content. Your hooked function will get the message as the first argument and the user’s reset key as the second. <?php add_filter(‘retrieve_password_message’, ‘wpse103299_reset_msg’, 10, 2); function wpse103299_reset_msg($message, $reset_key) { // … } retrieve_password_title for the the email subject. <?php add_filter(‘retrieve_password_title’, ‘wpse103299_reset_subject’); function wpse103299_reset_subject($subject) { // … … Read more

Send automatic mail to Admin when user/member changes/adds profile

you got the first part right about using personal_options_update but to be on the safe side add edit_user_profile_update also. and as for sending emails within WordPress the best way would be to use wp_mail, So something like this: add_action( ‘personal_options_update’, ‘notify_admin_on_update’ ); add_action( ‘edit_user_profile_update’,’notify_admin_on_update’); function notify_admin_on_update(){ global $current_user; get_currentuserinfo(); if (!current_user_can( ‘administrator’ )){// avoid sending … Read more

wp_mail script with jQuery post

Basically, you can use JavaScript to post to a WordPress function, then the WordPress function can invoke wp_mail() to send the message. A great place to start would be the useful AJAX in Plugins article on the Codex. It walks you through all the steps required to add your JavaScript on the front-end, your PHP … Read more

Writing a plugin that notify my friends of new post that mentions(@) them

Twice edited according to kaiser’s suggestions, unsecure version removed. <?php function my_email_friend($post_id = ”) { // get post object $post = get_post($post_id); // get post content $content = $post->post_content; // if @David exists if( 0 !== preg_match(‘/(@\w)/’, $content, $matches) ) $friend_display_name_like=”%” . like_escape($matches[0]) . ‘%’; else return; // do nothing if no matches global $wpdb; … Read more

Email confirmation on registration

I had to implement this for a client site and ended up creating my own system. I hash the email and date created timestamp and store it as a key in usermeta, then i email that key to the user’s email in the form of a link. The link points to a page where I’ve … Read more

How do I override the Message-ID header of wp_mail function?

You can filter the $phpmailer object. Something like this should do the trick (not tested): add_action( ‘phpmailer_init’, ‘wpse_52555_msg_id’ ); function wpse_52555_msg_id( &$phpmailer ) { $msg_id = get_post_meta( get_the_ID(), ‘messageID’, TRUE ); ” !== $msg_id and $phpmailer->MessageID = $msg_id . ‘@test.com’; }

Allow Duplicate Email Address for Different Users

Unfortunately, this just isn’t possible. There are three occasions where WordPress performs this check: When you click ‘save’ on the edit user screen( https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/user.php#L157 ) When a user is registered ( https://github.com/WordPress/WordPress/blob/master/wp-includes/user.php#L2023 ) When a user is created/inserted into the dtabase ( https://github.com/WordPress/WordPress/blob/master/wp-includes/user.php#L1610 ) Both (1) and (2) have hooks after them which allow you … Read more

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