Support » Plugin: ALO EasyMail Newsletter » Send to Role – now send emails to unsubscribed users.

  • Hi i use “Filter users according to roles…” before send emails

    So i select user role, but emails are send to ALL USERS from that role even if they are selected option NO to “Yes, I would like to receive the Newsletter” in their profile.

    So users that are unsubscribed receive emails.
    Is ti possible to change that? or

    Can we use some filter function to stop (exclude) emails for users that are selected option “NO” for the option – “Yes, I would like to receive the Newsletter”

    Any help will be very useful to me, thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter toto

    (@toto)

    Its very important to add a checkbox in settings menu “Dont send emails to roles for users who are selected NO” in their profiles “Yes, I would like to receive the Newsletter”

    pls help

    Thread Starter toto

    (@toto)

    Other suggest to add column to wp users list with status of user is subscribed or no

    try this code

    
    add_filter( 'manage_users_columns', 'rudr_modify_user_table' );
    function rudr_modify_user_table( $columns ) {
    	$columns['newsletter_status'] = __("Newsletter", "alo-easymail"); // add new
    	return $columns;
    }
     
    add_filter( 'manage_users_custom_column', 'rudr_modify_user_table_row', 10, 3 );
    function rudr_modify_user_table_row( $row_output, $column_id_attr, $user ) {
    	switch ( $column_id_attr ) {
    		case 'newsletter_status' :
    				$user_info = get_userdata( $user);
    				$optout_selected = '---';
    				if (alo_em_is_subscriber($user_info->user_email)){       // added ALO
    					$optout_selected = __("Yes");
    				} 
    			return $optout_selected;
    			break;
    		default:
    	}
    	return $row_output;
    }
    
    
    Plugin Author eventualo

    (@eventualo)

    Hi toto, there is a difference if you like to send to “subscribers” or “registered users”.

    If you select “subscribers”, the plugin searches for subscribers, that means: all not-registered guests that subscribed with the widget form, and the registered users that selected “Yes, I would like to receive the Newsletter”. You are sending to the people that subscribed to newsletters.

    If you select “registered users”, the plugin searches for users, regardless of their choice about newsletters: you are looking for users, not for subscribers. In this way you are sending to your blog users, not newsletter subscribers.

    I hope it helps.

    Thread Starter toto

    (@toto)

    Yes i understand but is there any possibility to “hack” sending email to role, to check if user is subscribed and not send to users with No
    can i use add_filter(‘wp_mail’ to do this,

    Any help with code will be very helpful

    Thank you

    Plugin Author eventualo

    (@eventualo)

    Ok, there is a plugin hook to remove a recipient from the queue.
    This is the code. I haven’t tested it but it should work. Anyway, I hope it could be a good starting point.

    
    /** 
     * To remove a recipient from the sending queue if it is an user but not subscriber
     */
    function my_easymail_maybe_remove_from_queue( $recipient ) {
    	global $wpdb;
    
    	// Check if the recipient is a registered user but not subscriber
    	if ( get_user_by( 'email', $recipient->email ) && ! alo_em_is_subscriber( $recipient->email ) ) {
    
    		// Mark it as sent to not find it again on next queue check
    		$wpdb->update( "{$wpdb->prefix}easymail_recipients",
    			array( 'result' => '1' ),
    			array( 'ID' => $recipient->ID )
    		);
    
    		// Return false to remove from queue
    		return false;
    	}
    
    	return $recipient;
    }
    
    add_filter( 'alo_easymail_recipient_in_queue', 'my_easymail_maybe_remove_from_queue' );
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Send to Role – now send emails to unsubscribed users.’ is closed to new replies.