Collecting Secondary Email Addresses

It is possible to let your subscribers add a secondary email address and send newsletters to both email addresses.

To do this,

First, create a custom field for the secondary email as shown below:-

Create secondary email custom field

Next, add the following PHP code snippet to your site.

add_action(
	'noptin_email_sender_before_sending',
	function( &$sender ) {
		$recipients = array();
        // Loop over the current email recipients.
		foreach ( wp_parse_list( $sender->recipients ) as $recipient ) {
			$subscriber   = noptin_get_subscriber( $recipient );
			$recipients[] = $recipient;

            // If there's a subscriber matching the email address...
			if ( $subscriber->exists() ) {

                // Fetch their secondary email.
				$secondary_email = $subscriber->get( 'secondary_email' );
				if ( is_string( $secondary_email ) && is_email( $secondary_email ) ) {
					$recipients[] = $secondary_email;
				}
			}
		}

		$sender->recipients = $recipients;
	}
);

How it works:-

This code snippet runs just before Noptin sends an email.

It loops over the current recipients for the email and checks if they have a secondary email.

If they do, it also adds the secondary email as the address.

Tip:-

You can use any custom field label as the secondary email provided you replace line 14 in the above code snippet with the field key that was generated for your custom field.

Related Guides

  • Bounce Handling

    How to automatically delete subscribers who bounce or report your emails as SPAM

    Read More

  • Sync Subscribers

    Have you ever wished you had several newsletter sign-up forms on different websites that all collected subscribers into a single newsletter list? This guide shows you how to do that. Step 1: Create a listener on the master site. Open one of the sites and then create an automation rule that listens to incoming webhooks…

    Read More

  • Custom Fields

    One of the most powerful features of Noptin is its support for custom fields. You can use custom fields to store more information about your subscribers (such as their phone numbers and birthdays). This guide shows you how to create and edit custom fields. Creating Custom Fields To create a new custom field:- First, visit…

    Read More

  • Importing Subscribers

    Learn how to import subscribers from another system into Noptin.

    Read More

  • Subscriber Lists

    Subscriber lists allow you to categorize your subscribers, similarly to how you use normal categories in WordPress. You can set lists in such a way that subscribers can only be on a single list at a time or multiple lists at the same time. Unlike tags, subscribers can select their own lists either on the…

    Read More

  • Tagging Subscribers

    Learn how to manually or automatically tag or untag subscribers based on how they signed-up and the actions they take on your site. You can then filter email recipients by tags

    Read More

  • Double Opt-in

    This guide shows you how to enable double opt-in and how to edit the double opt-in email. Double opt-in means that subscribers will not receive any marketing emails unless they confirm their email addresses.

    Read More

  • Unsubscribing

    To comply with the CAN-SPAM act and other anti-spamming laws, Noptin allows you to add the [[unsubscribe_url]] merge tag to your emails to give your subscribers a way to unsubscribe from your newsletter. This is added by default to your newsletter’s footer text. You can, however, add it anywhere in the emails you send. Customizing…

    Read More

  • How to block newsletter subscribers

    Blocked subscribers are permanently excluded from your list—they won’t receive emails, and they can’t be re-added through forms, imports, or integrations.

    Read More

  • Bulk-delete newsletter subscribers

    Noptin allows you to bulk delete your newsletter subscribers. You can delete all your subscribers or filter them by:- This is useful, for example, if you have a comma-separated list of bounced emails and need to bulk-delete all of them. To do this:- First, open your admin dashboard and then click on Noptin > Email…

    Read More

  • Welcome New Subscribers

    74% of your subscribers expect a welcome email after they sign up for your email list. Invespcro A welcome email is the first email that you send to your subscribers after they sign up for your email list. To set up a welcome email:- First, click on Noptin > Email Campaigns > Automated Emails to…

    Read More

  • Automatically delete non-confirmed subscribers

    If you’ve enabled double opt-in, you can set up an automation rule that automatically deletes any subscriber who does not confirm their email address after a certain period. To do this:- First, open your admin dashboard and then click on Noptin > Automation Rules to open the automation rules overview page. Next, click the “Add…

    Read More