Add email addresses to already registered users

my website users register with phone number OTP. That's why they have no email address in their accounts. Today I need email address in user accounts. I use this code to add email address for new user registrations. add_action("user_register", function ($user_id) { $user = get_userdata($user_id); if (empty($user->data->user_email)) { $args = array( "ID" => $user->id, "user_email" => uniqid() . "@example.com", ); wp_update_user( $args ); } }); add_filter( 'bnfw_trigger_insert_post', '__return_true' ); But I have about 3000 users that need email address in …
Category: Web

How can all E-mails be sent with BCC copy to Admin?

I'm translating WordPress page into seven different languages. Have around 70 plugins active and working, no worries. Subscriptions, shop, pre-orders you name it. Getting there with translations, using WPML but I have not found, not even searching, all templates for emails going out to users, customers, shop editors, bloggers, etc. I'm sending all emails out through Mailster. Is there a way that would be Admin able to get BCC copy of each and every e-mail sending out? I would take …
Category: Web

How to send email with wp_mail() with from email taken from contact form instead of the host?

I have set up SMTL like this, add_action( "phpmailer_init", "send_smtp_email" ); function send_smtp_email( $phpmailer ) { ini_set("sendmail_from","[email protected]"); ini_set("sendmail_path","[email protected]"); // Define that we are sending with SMTP $phpmailer->isSMTP(); // The hostname of the mail server $phpmailer->Host = "localhost"; // Use SMTP authentication (true|false) $phpmailer->SMTPAuth = false; // SMTP port number - likely to be 25, 465 or 587 $phpmailer->Port = "25"; // Encryption system to use - ssl or tls $phpmailer->SMTPSecure = "tls"; $phpmailer->From = "[email protected]"; $phpmailer->FromName = "XYZ"; } and …
Category: Web

WordPress WooCommerce email notifications going to spam folder

I have just built a new WordPress site for a client, and repointed the domain's (mellowmarshfarm.com) DNS records to the new hosting service, Flywheel. The client's custom email address is hosted by a different provider, and the notifications for the site are forwarded from WordPress via fw-mail.com, but they are going to the client's and customers' spam folders. I have tried adding x.fw-mail.com to the mail host's SPF record, but it didn't make a difference: v=spf1 ip4:[redacted] include:spf.antispamcloud.com include:x.fw-mail.com +a …
Category: Web

Filter wp_mail based on content type

I can current filter the content type of the wp_mail function: add_filter( 'wp_mail_content_type', function( $content_type ) { return 'text/html'; }); And I can filter the message content add_filter( 'wp_mail', function( $args ) { $args['message'] = 'Filtered text here'; return $args; }); But how can I only do the latter conditionally? I only want to filter the message when the content type == text/plain. I'm guessing there is a super-simple solution to this, but I haven't worked it out yet.
Category: Web

User with same Mail but a different additional info(like domain)

I know this is not the way u should go, but my customers want it so im looking for ways. Requirement: WP with one DB (3 Domains sale the same stuff) 3 Domains which use this DB (can be more later), this should work with on fly rewriting over hooks user registered should be only able to login in the domain where he is registered, but should be able to register on the other 2 domains with same data. My …
Category: Web

How to login with email only no username?

After searching for a couple of days and reading 2 year old threads I'm having difficulty finding a solution to the problem of having users login by email only. At first I was delighted to see WP_Email_Login only to find out you can still use your username to login. I'm not sure how to go about writing this as a plugin. My idea is to override the register_new_user function. I didn't see this on the "pluggable" functions list. Can I …
Category: Web

Custom Welcome Email | WordPress

I want to replace the following message when creating a user in the dashboard as an administrator: Username: xxx To set your password, visit the following address: https://development.xxx.com/wp-login.php?action=rp&key=FlFdsDeAveg2EN1HuqGB0G&login=xxx%40gmail.com https://development.xxx.com/wp-login.php This is my non-working function: /** * Custom Welcome Email * @author Archie M * */ add_filter( 'wpmu_signup_user_notification_subject', 'my_activation_subject', 10, 4 ); function my_activation_subject( $text ) { return 'Welcome to xxx! (Activation required)'; } add_filter('wpmu_signup_user_notification_email', 'my_custom_email_message', 10, 4); function my_custom_email_message($message, $user, $user_email, $key) { //Here is the new message: $message = …
Category: Web

Adding extra email address who receives email like admin - woocommerce

Is there any way to add a new email address along with admin email who receives same email as the admin.like : on placing an order admin receives 'NEW ORDER RECEIVED' but customers receives 'THANKS FOR YOUR ORDER' I know how to add an email on placing order as customer but is there any way where admin and that added email recipient will receive same email.and after the order is placed remove that email.
Category: Web

wp_mail() not sending emails with ajax

I am using wp_mail() to send email using ajax. My mail code is as follow. add_action( 'wp_ajax_send_confirmation_email', 'wpse_sendmail' ); add_action( 'wp_ajax_nopriv_send_confirmation_email', 'wpse_sendmail' ); function wpse_sendmail() { if(isset($_GET['is_email']) && $_GET['is_email'] == true){ $temp_dir = get_template_directory_uri(); $url = $temp_dir."/confirm_email.php?id=".$_REQUEST['id']."&key=".$_REQUEST['key']; $message = "Username:".$_REQUEST['name']."Click on below link to confirm your email;".$url; $subject = "Email confirmation Link"; $headers = "From: [email protected]" . "\r\n"; if ( wp_mail( $_REQUEST['email'], $subject, $message, $headers ) ) { echo "1"; } else { echo "0"; } } } And AJAX …
Category: Web

User Without Email?

When creating a user in Wordpress an email address is required for that user. The website I'm working on requires that users remain anonymous (it's part of a research study) and I'd consider email to be an identifying piece of data. Users will be added manually, so email is not required to confirm accounts or prevent spam sign-ups. Am I going to have to provide a fake email address for each account, or is there a way to leave this …
Category: Web

Send mail to author when custom post type is saved

I have a custom post type called "documents". I can add documents (ACF repeater field) there and the users can see them in a frontend-view. Now i need to send an email-notification to the author of the post when i change the custom-post-type in the backend and save it. In another project i worked with the following function in the functions.php file, but this code is just working when i create a new post. I don't need to send mails …
Category: Web

Mailing issues with wordpress?

I'm working on a client's website and they are not getting messages from the site anymore. I've found that no mail will go to an email address ending in @gmail.com, I can send mail just fine to anyone within my company that has an email with a custom domain. But a Gmail inbox the messages never even seem to make get close. They're not in spam, not in promotions, nowhere. I've installed WP mail log, and see no errors on …
Category: Web

Woocommerce checkout page - custom field checkbox value into email

I've added a checkbox to the checkout page: add_action('woocommerce_after_order_notes', 'client_already_field'); function client_already_field( $checkout ) { echo '<div id="client-already-field"><h3>'.__('CLIENT ALREADY? ').'</h3>'; woocommerce_form_field( 'client_already_checkbox_yes', array( 'type' => 'checkbox', 'class' => array('input-checkbox-yes'), 'label' => __('YES!'), 'required' => false, ), $checkout->get_value( 'client_already_checkbox_yes' )); echo '</div>'; } And saved it to order meta (both of these functions worked): //1 add_action('woocommerce_checkout_update_order_meta', 'client_already_order_meta_yes'); function client_already_order_meta_yes( $order_id ) { if ($_POST['client_already_checkbox_yes']) update_post_meta( $order_id, 'Client Already:Yes', esc_attr($_POST['client_already_checkbox_yes'])); } // 2 function client_already_order_meta_yes( $order_id ) { if( !empty( $_POST['client_already_checkbox_yes'] ) …
Category: Web

Would like to use hook or filters to customize email templates

I hired a contractor to help me with my site a few years ago when I didn't have the coding experience that I do today. The contractor ended up making new templates for almost every email, and they are all out of date. I started making updates to them when I realized I should just be making the custom changes in the functions.php page so I don't have to go through updating a billion templates each time WooCommerce makes an …
Category: Web

Duplicate notifications for new user registration

I am trying to figure out why new user registrations are receiving duplicate notification emails. They arrive at the exact same time but from different addresses, one is from the admin owner (myself) and the other one from [email protected]. I am using a custom registration form. Here are the relevant pieces of code: // auto generate a password $user_pass = wp_generate_password(); // setup new user $userdata = array( 'user_pass' => $user_pass, 'user_login' => esc_attr( $_POST['user_name'] ), 'user_email' => esc_attr( $_POST['email'] …
Category: Web

Get value from an input field and pass into update_meta_data as $meta_value

I am building a woocommerce site and I have some input fields the on the product page. one is for recipient email (its for a gift car). Everything works, and the recipient email is saved on the order, but I want to be able to pass the email address to a function to update_meta_data so that I can use in other parts of the code (namely to send out a separate email to the recipient to redeem the card). here …
Category: Web

how to remove email field from default user registration form on wordpress

Due to some privacy policy i don't want to store user personal information such as First Name, Last Name and Email address in wordpress database. for this I want to signup user with only username and password at the default WP Registration form, can any one let me know how to remove the email field from the default wordpress registration form. what code need to I change in my wordpress theme, please suggest!
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.