• Resolved jkocken

    (@jkocken)


    I tried to use shortcode for hiding a specific text content like this:
    [members_not_logged_in]
    The items on this page are only available to purchase for logged in members.
    [/members_not_logged_in]

    but it doesn’t show any text for logged out users and neither for logged in users. What am I doing wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Caseproof

    (@caseproof)

    Hi @jkocken

    Your shortcode:

    [members_not_logged_in]
    The items on this page are only available to purchase for logged in members.
    [/members_not_logged_in]

    should display “The items on this page are only available to purchase for logged in members.” message for not logged in users, but we don’t have any attributes to display message for logged in users. I passed this on to our developer so it should be added in the future release. In the meantime you can try to add this code at the end of your theme’s functions.php file to display custom message to logged in users:

    add_filter( 'do_shortcode_tag','custom_logged_out', 10, 3);
    function custom_logged_out($output, $tag, $attr){
      if('members_not_logged_in' != $tag) {
        return $output;
      }
      if($output === ''){
        return 'Custom message...';
      }
      return $output;
    }
    Thread Starter jkocken

    (@jkocken)

    Thanks for your reply. It works now for not-logged-in customers (I think I had some caching problem earlier) so that solves my problem.
    p.s. on your documentation page, the shortcodes are not easy to understand because the underscores are missing. you might want to fix that ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to use shortcodes?’ is closed to new replies.