• Resolved gabi_cavaller

    (@gabi_cavaller)


    What a great plugin, thank you.

    I want to restrict content on a page, to non-registered users.

    I have used your plugin in the following method;

    Page heading
    
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. [This section is for everyone to see]
    
    [hide for="logged"] LOGIN OR REGISTER TO READ MORE...............  [/hide]  [This section is HIDDEN IF USER IS LOGGED IN - they don't need to see it, redirects them to login or registration page]
    
    [hide for="!logged"] [If the user is not logged in, hide this section until the close hide tag]
    
    ADDITIONAL TEXT ONLY AVAILABLE TO LOGGED IN USERS
    
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    How can I make it, more of an easier way to implement the above? Happy to contribute towards this. Thank you

    https://www.ads-software.com/plugins/hide-this/

Viewing 1 replies (of 1 total)
  • Plugin Author Andrés Villarreal

    (@andrezrv)

    Hi Gabi,

    Thank you for your kind words ??

    It really depends on where you’re using the shortcode. If you’re doing it through the post editor, what you did is the only way. But if you’re using the shortcode in a template, you can do something like this:

    if ( class_exists( 'Hide_This' ) ) :
        if ( $content = new Hide_This( array( 'for' => '!logged' ), get_the_content() ) ) :
            echo $content;
        else :
            echo 'Login or register to read more';
        endif;
    else:
        the_content();
    endif;

    The Hide_This class is what the shortcode uses internally to hide content, but you can take more advantage of it using it inside PHP code.

    Hope this helps.

    Best,

    Andrés.

Viewing 1 replies (of 1 total)
  • The topic ‘Read more….’ is closed to new replies.