Home Forums Newsletter Plugin Support function is_subscribed() ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #20267
    ianumeda
    Participant

    Hello,

    Is there a function that allows you to determine if a user is subscribed via your plugin? And to which lists? Something like:

    function is_user_subscribed() {…}

    Thank you!

    Ian

    #20380
    Stefano
    Keymaster

    You can try Newsletter::->instance()->get_user($email). If null is returned the user is not present. If present you can check the returned object status property.

    #20960
    ianumeda
    Participant

    Thank you Stefano. Although I’m not sure how to use that code. Is the Newsletter object available globally in PHP? And would I need to know what $email address to pass into the get_user() function?

    #20998
    ianumeda
    Participant

    Stefano, you had a bug in your code:

    Newsletter::->instance()->get_user($email)

    should be

    Newsletter::instance()->get_user($email)

    but the simpler answer to my question is just call the function:

    Newsletter::shortcode_newsletter_lock($content)

    … which acts in the exact same way as using the short code except you can put this into your templates.

    #20999
    ianumeda
    Participant

    Silly me – the real answer was to use do_shortcode like this:

    <?php echo do_shortcode(“[newsletter_lock]”.$locked_content.”[/newsletter_lock]”); ?>

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.