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.
Related
In Woocommerce, there is already a built-in way to add recipients to the "New Order" , "Failed", and "Cancelled" emails, but for some reason, the "Customer invoice / Order details" don't allow any recipient other than the customer.
There is a simple plugin that allows for that, but it is very limited in features.
Any guidance for how to add recipients to this email?
I plan to use a Code Snippet to call the hook/filter/action and then tell it explicitly which email addresses to use. I intend to write the script so that whatever user initiates the action, will be CC'ed on that email. Presumably the same function that can do the first part of my question can help me to check current user and will grab their email address.
Any help is appreciated
I don't know what buil-in functionality are you talking about. But you can use the below filter to add recipients to the invoice email. You don't need any plugin, just use this below code snippet in your active theme/child theme functions.php
add_filter("woocommerce_email_recipient_customer_invoice", "add_recipient_to_email", 10, 2);
function add_recipient_to_email( $recipients, $object ){
$new_email = "newemail#domain.com"; //New email Id
$recipients = $recipients.','.$new_email;
return $recipients;
}
I'm looking to disable the standard "You have reset your password" email in Wordpress for a user.
Is it possible to expand on that? I'm pretty sure the following disables the email:
/**
* Disable User Notification of Password Change Confirmation
*/
add_filter( 'send_password_change_email', '__return_false' );
Could I combine that with something else when that fires?
Essentially I want to use another mailing service to send the email using the following:
$this->sendinblue_send_template($customer_email, 6);
So how can I combine the two and use my snippet of code when the password change email fires?
I suggest you to build an plugin, this is the code to build an plugin that you need
and you can using this filter like this:
// define the send_password_change_email callback
function filter_send_password_change_email( $send, $user, $userdata ) {
$send = false;
// write the code if you want to send to other email provider
return $send;
};
// add the filter
add_filter( 'send_password_change_email', 'filter_send_password_change_email', 10, 3 );
I'd like to disable the standard Wordpress changed password (to the user) and send an email via a different system (in this case Send In Blue).
I've had a look around and found that this disables the email
add_filter( 'send_password_change_email', '__return_false' );
This is my code to send a particular template from Send in Blue:
$master->sendinblue_send_template($user_info->user_email, 34);
How can I combine the two? So when a user resets their password, the Send in Blue template is sent to them instead.
You can write a custom function and then call that function in your filter.
function send_custom_mail ()
{
$res = sendinblue_send_template($user_info->user_email, 34);
return false;
}
add_filter( 'send_password_change_email', 'send_custom_mail ');
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.
I am trying to add a function that will log any email that is sent through order status changes.
Is there a hook I can use that is triggered right before an order notification email is sent?
Updated
All the available hooks responsible for triggering email notifications are located in WC_Emails init_transactional_emails() method and are action hooks:
woocommerce_low_stock,
woocommerce_no_stock,
woocommerce_product_on_backorder,
woocommerce_order_status_pending_to_processing,
woocommerce_order_status_pending_to_completed,
woocommerce_order_status_processing_to_cancelled,
woocommerce_order_status_pending_to_failed,
woocommerce_order_status_pending_to_on-hold,
woocommerce_order_status_failed_to_processing,
woocommerce_order_status_failed_to_completed,
woocommerce_order_status_failed_to_on-hold,
woocommerce_order_status_on-hold_to_processing,
woocommerce_order_status_on-hold_to_cancelled,
woocommerce_order_status_on-hold_to_failed,
woocommerce_order_status_completed,
woocommerce_order_fully_refunded,
woocommerce_order_partially_refunded,
woocommerce_new_customer_note,
woocommerce_created_customer.
Each of those action hooks can queue or send transactional emails as you will see in the source code on line 95 or on line 99.
Last thing for the new order notification, which is a bit appart, you will use one of those:
woocommerce_order_status_pending_to_processing_notification,
woocommerce_order_status_pending_to_completed_notification,
woocommerce_order_status_pending_to_on-hold_notification,
woocommerce_order_status_failed_to_processing_notification,
woocommerce_order_status_failed_to_completed_notification,
woocommerce_order_status_failed_to_on-hold_notification,
as documented in this WC_Email_New_Order code source.
Or you can detect status changes using one of the 3 hooks located in status_transition() WC_Order method:
woocommerce_order_status_changed
woocommerce_order_status_{$status_transition[from]}_to_{$status_transition[to]}
woocommerce_order_status_{$status_transition[to]}
The status_transition() is included in set_status() WC_Order method (and so also update_status() method too which call set_status()).