This topic has 8 replies, 3 voices, and was last updated 9 years by Radu.

  • Author
  • #81687
     Vanessa
    Participant

    Is it possible to hide/show shortcode based on whether the user is logged in or not?
    I’ve got a login prompt that is made using a shortcode from the visual editor that I’d like to hide if the user is logged in. This prompt is in a widget – I’d like to do it in a widget and a post (menu is clear enough how to do)

    thx
    v

    #81900
     Laura
    Moderator

    Hello, yes it is possible, could you share a link and show me what do you want to hide? 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #81902
     Radu
    Moderator

    Hi,

    See this small video : https://drive.google.com/file/d/0Bxo5b6iHWRMwMUZpa2RpeW1xUG8/view

    COPY CODE
    
    [kleo_restrict type="guest"]<h1>This text will be displayed only for guest users </h1>[/kleo_restrict]
    

    Best Regards

    Radu

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #83064
     Vanessa
    Participant

    Radu you are a magician! Thank you!
    Is there a way to restrict based on user levels defined by paid memberships pro?

    My scenario is – I want to show an upsell prompt ‘get our more awesome plan’ to users at a lower tier, even though they are logged in.

    #83208
     Radu
    Moderator

    Hi,

    Please take a look,test and adapt this snippet for your requirements

    COPY CODE
    
    //1,2 represents id's of packages that you want to see your message
    function CheckMemberships() {
     
    if(pmpro_hasMembershipLevel(array(1,2), get_current_user_id())){
        echo 'Please update your account to GOLD membership <a href="/">Link</a>'
    ;}
    }
    add_action('wp_head', 'CheckMemberships');
    

    Add this code to your kleo-child/functions.php

    Best Regards

    Radu

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #84061
     Vanessa
    Participant

    Thanks, is there a way to have the same shortcode behavior for PMPRO membership levels?
    [kleo_restrict type="Gold"]<h1>This text will be displayed only for gold users </h1>[/kleo_restrict]

    Also, for logged in users I’m using [kleo_restrict], but it seems to be missing an argument. What should I use for the argument?

    #84252
     Radu
    Moderator

    Hi,

    COPY CODE
    
    Shortcode Examples
    
    [membership]
    	Will show up for all members
    [/membership]
    
    [membership level="1"]
    	Will only show up for level 1 users
    [/membership]
    
    [membership level="1,2,3"]
    	Only show for level 1, 2, or 3 users
    [/membership]
    
    [membership level="0,-1"]
    	Show for anyone not in level 1, including non-members and visitors.
    [/membership]
    
    [membership level="0"]
    	Will show up for non-members and non-logged in site visitors.
    [/membership]
    

    Source: http://www.paidmembershipspro.com/documentation/content-controls/with-shortcodes/
    If you want to see the page, you need to have an account, you can create one is free.

    Regards

    Radu

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #85180
     Vanessa
    Participant

    Oh perfect! I didn’t think to look at PMP Pro documentation, I was looking for this somewhere on the Kleo Docs.

    This is awesome, thanks.

    Are you folks looking at updating the Kleo Docs? Might be worth adding a few links to the tools (RTMedia, PMP, …) that you include.

    Thanks for your help Radu!

    #85525
     Radu
    Moderator

    Hi,

    You’re welcome

    Yes in future we will update the documentation.

    Regards

    RAdu

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 9 posts - 1 through 9 (of 9 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?