Editing the Wordpress "Notice of Email Change" email text - php

If I log in to Wordpress as an admin and change another user's email address, the following email is automatically sent to that user saying the following:
Hi [username], This notice confirms that your email was changed on [website]. If you did not change your email, please contact the Site Administrator at [admin email] This email has been sent to [user email] Regards, All at [website] [website url]
Is there a way to edit this message to say something else?

You would use the email_change_email filter. Learn about this filter in the WordPress Codex. Also learn about it on hookr.io
Learn about adding filters here.
/* Filter Email Change Email Text */
function so43532474_custom_change_email_address_change( $email_change, $user, $userdata ) {
$new_message_txt = __( 'Change the text here, use ###USERNAME###, ###ADMIN_EMAIL###, ###EMAIL###, ###SITENAME###, ###SITEURL### tags.' );
$email_change[ 'message' ] = $new_message_txt;
return $email_change;
}
add_filter( 'email_change_email', 'so43532474_custom_change_email_address_change', 10, 3 );

Just edit below file from root directory located in /wp-includes/user.php line no. 2064 or search for 'Hi ###USERNAME###, and you will find the message body as below that you can customize it as you would like.
$email_change_text = __(
'Hi ###USERNAME###,
This notice confirms that your email address on ###SITENAME### was changed to ###NEW_EMAIL###.
If you did not change your email, please contact the Site Administrator at
###ADMIN_EMAIL###
This email has been sent to ###EMAIL###
Regards,
All at ###SITENAME###
###SITEURL###'
);

Related

Using Advanced Custom Field value as "Email to" in Contact Form 7

I'm creating a page in which you submit a Contact Form 7 to the email based on what email is added to the job_email field via my Advanced Custom Fields.
I have attempted to add the form via the PHP shortcode like this
[email* dynamic-email class:email-address placeholder "Email Address*"]
echo do_shortcode('[contact-form-7 id="234" title="Dynamic Submit CV" dynamic-email="'.get_field( 'job_email' ).'"]' );
The fields all display correctly, and upon submitting the email successfully, the email never receives the form. Meaning I am totally missing something here.
If I understand correctly, what you are after is send a notification with the entry details to the email address inputted on the job_email field.
If so, what you want to do is to set up an email on the email tab and in the To: setting put [job_email].
Update
As you stated in the comment, the email has to be the one set in the backend. You can guarantee the email notification to be sent to the ACF-based email via hooks, specifically the wpcf7_mail_components hook.
function so57013385_mail_components( $components, $number ) {
$job_mail = get_field( ... );
$components['recipient'] = (array) $components['recipient'];
$components['recipient'][] = $job_mail;
return $components;
};
add_filter( 'wpcf7_mail_components', 'so57013385_mail_components', 10, 2 );
Note: I'm casting the $components['recipient'] variable to array just to make sure the email is appended correctly, as this parameter is passed directly to wp_mail(), which can receive a string or an array. Also, you might need to add more validations on the form ID, sanitization, etc. The above code is not tested.

wp_mail use WordPress's default email template for sending email

Is there any way to send email from WordPress using the default template that WordPress uses for sending emails (on registration, password reset etc).
I'm using wp_mail function for sending email, but how to include the template in the message with custom contents.
Thanks
Try using this tutorial: https://www.wpbeginner.com/plugins/how-to-change-sender-name-in-outgoing-wordpress-email/
You will need to add the following code in your theme’s functions.php file or a site-specific plugin.
// Function to change email address
function wpb_sender_email( $original_email_address ) {
return 'tim.smith#example.com';
}
// Function to change sender name
function wpb_sender_name( $original_email_from ) {
return 'Tim Smith';
}
// Hooking up our functions to WordPress filters
add_filter( 'wp_mail_from', 'wpb_sender_email' );
add_filter( 'wp_mail_from_name', 'wpb_sender_name' );
This code simply replaces the default WordPress sender name and email address with your custom sender name and email address.

TYPO3 form - password forgot link change E-Mail content

I have a login form on my page. I found an option in the backend so that users can reset their password.
I tried it and it works, I received an E-Mail with a link to a page where I can change the password.
However, I try to change the content of the E-Mail because I don't like it.
I found this:
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['forgotPasswordMail']
Hook to change the contents of the forgot password mail
https://docs.typo3.org/typo3cms/extensions/felogin/Hooks/Index.html
I found this "Tutorial" which shows how to use hooks, but it is missing some important information. Where exactly do I have to do the manipulation? In which file? How exactly do I replace the content?
You can "simple" change the lang parameters for felogin to change the email content.
plugin.tx_felogin_pi1._LOCAL_LANG {
default {
ll_forgot_email_password (
... Your Text here for emails with password ...
)
ll_forgot_email_nopassword (
... Your Text here for emails where password can not found ...
)
ll_forgot_validate_reset_password(
... Here Text for emails with password reset link ...
)
}
}
You can see the default Text with placeholders here.
There first line of the translation is used as the subject of the email.

How to use a WordPress shortcode in a URL?

I have created a WordPress shortcode in functions.php that looks like this:
function user_email() {
}
add_shortcode( 'user_email', 'user_email' );
This captures the logged-in WordPress user's email address. I want to pass that email address in a query string, so the end result would look like this:
https://ofcoursebooks.com/bmf?email=ashli#example.com
To do that, I was hoping to pass the email address via the short code:
https://ofcoursebooks.com/bmf?email=[user_email]
That doesn't seem to be working though... it just passes the actual [user_email] text.
What did I miss?

Any way to have wp_mail not send a “registration denied” email?

I'm using the approve new userplugin and the FAQs say that emails are generated through the wp_mail() function. Is there a way to not send a denied email to users when not approving their registration?
If you view the plugin source, you'll notice that the deny_user() email is sent during the 'new_user_approve_deny_user' hook. Therefore, you can use the following in your functions.php to remove the action:
remove_action( 'new_user_approve_deny_user', array( pw_new_user_approve(), 'deny_user' ) );
Read more about the remove_action() function in the Codex.

Categories