Show or Hide Content

Overview

LearnDash includes some great shortcodes for showing content to learners that are enrolled in courses as well as users that aren’t enrolled—the [visitor] and [student] shortcodes. These are great on course pages, but what about inside Open courses and elsewhere on a LearnDash site? Sometimes you may want to show content based on the user’s signed-in state rather than whether or not they’re enrolled in a course. We use this a lot when we want to hide content from anonymous visitors (while still giving them a taste of what’s available) and encourage users to create an account to view free course materials.

Live Demo

See this module in action on our LearnDash demo site!

Shortcodes

We include a [uo_show] shortcode in the Toolkit that make it easy to show content based on signed-in state. Here are some examples of how to use the shortcode:

[uo_show for='loggedin']Content for logged in users[/uo_show]

That example displays the text to users that are signed in. This might be useful in an Open course to display special bonus content, like a video or download.

[uo_show for='loggedout']Content for logged out users[/uo_show]

That example displays the content for users that aren’t signed in. This is helpful for calls to actions and other marketing that isn’t relevant to signed-in users.

Was this article helpful?
8 replies
  1. NICE
    NICE says:

    in courses i enable hide course (edit courses) but content is still showing non logged users why?

    content table is showing in given link why?

    Reply
    • Ken Young
      Ken Young says:

      Hi there, it looks like you were able to get the content table hidden. Regarding the content showing; that’s something you could ask LearnDash, as the setting is built into LearnDash and not related to our plugins. Thanks!

      Reply
  2. Rashid Herrera
    Rashid Herrera says:

    Hello.

    I need at less 2 user catgories: Students 1 and students2.
    May be I can get this done with: Cimy User Extra Fields.

    Then both will take the same curse, but for students 2 I will need the are able to see more lessons.
    In other words, I need hide some lessons to students 1

    Can I use this little script or similar?

    thanks

    Reply
    • Ryan
      Ryan says:

      This should not be done, I’m afraid. You can’t make lessons optional in LearnDash, and if you did hide the lessons then users that didn’t see the lessons could never complete the course and progress wouldn’t be tracked properly. It won’t work; you should use a second course if some users see different lessons.

      Reply
  3. Alex Rengel
    Alex Rengel says:

    Is it possible to restrict a whole page depending on a user’s login status? I can already hide menu items based on a user’s logged in status, but is there a way to restrict logged out users from even getting to a page, even if they had the URL? The best solution would be to redirect them to a different page where I can prompt them to log in or get in touch.

    Reply

Comments/Questions

Please note that this is not a support forum. If you are experiencing issues on your site, please open a support ticket instead. Site-specific support questions submitted as comments will be unanswered.

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest