Key Controls
User’s access to a particular Course
You can show or hide HTML elements, menus, and other details based on user’s enrollment in LearnDash course.
User is Logged In or
Logged Out
You can show or hide HTML elements, menus, and other details based on user’s status like logged in or logged out.
User is a member of
a LearnDash Group
You can show or hide HTML elements, menus, and other details by checking user’s access to a particular LearnDash Group.
How to Use?
You simply need to add a CSS class to your element div or span.
As explained here, if Course or Group ID is 123
Login/Logout Status:
Add this CSS class: visible_to_logged_in OR hidden_to_logged_out
Add this CSS class: visible_to_logged_out OR hidden_to_logged_in
For all the courses:
Add this CSS class: visible_to_course_all
Add this CSS class: hidden_to_course_all
Add this CSS class: visible_to_course_none
Add this CSS class: hidden_to_course_none
For a specific course, if Course ID is 123:
Add this CSS class: visible_to_course_123
Add this CSS class: hidden_to_course_123
For users with access to at least one course, add this CSS class: hidden_to_course_none
For all the groups:
Add this CSS class: visible_to_group_all
Add this CSS class: hidden_to_group_all
Add this CSS class: visible_to_group_none
Add this CSS class: hidden_to_group_none
For a specific group, if Group ID is 123:
Add this CSS class: visible_to_group_123
Add this CSS class: hidden_to_group_123
For users with access to at least one group, add this CSS class: hidden_to_group_none
Mechanism of Functioning
- Multiple CSS Classes: If multiple visibility control classes are added, ALL of them must meet the criterion to keep the element visible. If any one of them hides the element, it will be hidden. For example: visible_to_group_123 visible_to_group_124 will show the element only to those who have access to both groups.Hidden data/elements reach the browser. Though users do not see it.
- CSS is added to the page for all CSS elements that need to be hidden based on the above rules.
- After the page is loaded. These elements are removed from the page using jQuery (if available), so it won’t be available even on Inspect.
- Elements rendered after the page load are hidden but not removed from DOM/page.