Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author eventualo

    (@eventualo)

    You can know if a guest is a newsletter subscriber only if is a logged user: you can get the user email and check if there is a subscriber with this email.
    No chance to know about not-logged guest: there is no memory of guest subscription.
    So the following code give you the subscriber details of a logged user who is also a newsletter subscriber:

    function my_easymail_custom_filter_content ( $content ) {
    	global $user_email;
    
    	if ( is_singular('newsletter') && $user_email ) {
    
    		if ( $subscriber_id = alo_em_is_subscriber( $user_email ) ) {
    			$user_lists = alo_em_get_user_mailinglists( $subscriber_id );
    
    			// Add content for list id 1
    			if( in_array( '1', $user_lists) ) {
    				$content .= '<h2>Content for list 1</h2>';
    			} 
    
    			// Add content for list id 2
    			if( in_array( '2', $user_lists) ) {
    				$content .= '<h2>Content for list 2</h2>';
    			}
    
    			// ....
    		}
    	}
    	return $content;
    }
    add_filter ( 'the_content',  'my_easymail_custom_filter_content' );
    Thread Starter jenkit

    (@jenkit)

    Thanks. Your code is awesome for newsletter preview while editing it in admin area.
    What I’m trying to achieve is to let subscriber to view his just received newsletter in the browser after he clicks “preview on-line” link. Let’s say there’s subscriber name in email content and I’d like to this same name appear in email’s on-line preview. So is there a way to pass that name (recipient data in general) from email (viewed in mail client e.g. gmail) to on-line preview (browser)?

    Plugin Author eventualo

    (@eventualo)

    I understand your point. For now it’s not possible, you should write some custom php using plugin hooks. Good remark, it could be an idea for future releases.

    Thread Starter jenkit

    (@jenkit)

    I found somewhere that in template php are 2 objects available: $newsletter and $recipient. But I can’t get their data in on-line newsletter preview. Am I missing something? Thanks

    Thread Starter jenkit

    (@jenkit)

    Ok. I’m almost there. Idea: How about filtering content of [READ-ONLINE-URL] by adding query var with receiver id? And using that id on on-line preview to retrieve recipient data? What filter should I apply and can I use alo functions e.g. alo_em_is_subscriber() on on-line preview (in single-newsletter.php)? Thanks a lot.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Getting subscriber and mailing lists data in on-line preview’ is closed to new replies.