WordPress Integration and Conditional Tags

Discussion in 'Integration' started by sheridan_road, Dec 17, 2013.

  1. sheridan_road

    sheridan_road New Member

    Joined:
    Dec 12, 2013
    Messages:
    6
    Hello,

    Regarding your WordPress integration plugin, I understand that users can protect content using shortcodes in the text editor (or using the do_shortcode function in a theme file).

    However, have you developed conditional tags as well?

    For example:

    Code:
    <?php
     
    if ( is_amember_guest() ):
     
      // do something
     
    else:
     
      // do something else
    ?>
    Or:

    Code:
    <?php
     
    if ( amember_product_active(2) ):
     
    // do this
     
    elseif ( amember_product_active('premium') ):
     
    // do that
     
    endif;
     
    ?>
    I don't see anything in the documentation, but would be a very powerful way for theme developers to control what users see based on subscription level or guest status.

    The shortcodes are a bit cumbersome and don't have the same flexibility or power that conditional functions would.

    Thanks.

    J
  2. borise

    borise Member

    Joined:
    Jan 3, 2013
    Messages:
    42
    Hi J.

    this is possible with shortcodes. Check out the aMember Shortcodes Help module under a post for possibilities and examples.

    Your first example would be:
    Code:
    [am4guest]Welcome guest user! Please login here: [am4info var=loginurl] [/am4guest]
    and your second example:
    Code:
    [am4show have='p1' user_error='amember_error' guest_error='amember_guest_error']
    Hope that helps!
  3. sheridan_road

    sheridan_road New Member

    Joined:
    Dec 12, 2013
    Messages:
    6
    Thanks for the reply.

    Let me ask you a question:

    If you wanted to use shortcodes to display WordPress content based on subscription level, how would you do this?

    For example, if you wanted to display "the_content()" for subscribed users, and "the_excerpt()" for guests, you cannot do this using shortcodes.

    Using "get_the_content()" displays unformatted output, without paragraph tags. Using just "the_content()" displays regardless of subscription status.

    Shortcodes are not meant to be used in theme files. They are meant to be used in the text editor.

    This is unfortunate. Wouldn't take much work on Amember's part to create booleans that would allow developers to display one block of code if user is subscribed, and another if not, and allow us to fully use WordPress template tags.
  4. sheridan_road

    sheridan_road New Member

    Joined:
    Dec 12, 2013
    Messages:
    6
    The answer to this question is that it is possible.

    There is a class that can be accessed with methods that accomplish what I was asking.

    Here's a link to the page that lists the available methods and the location of the class:

    http://www.amember.com/docs/API/Lite

    Hope that helps anyone else asking the same question.

    J
    littlesage likes this.

Share This Page