
內容簡介
Visibility Control for LearnPress 能夠幫助您隱藏 WordPress 頁面上任何特定標准下的信息和內容。
根據以下標准,您可以顯示/隱藏 HTML 元素、菜單和其他細節:
1. 用戶對於特定 LearnPress 課程的訪問權限,或
2. 用戶是否已經登入或登出。
3. 用戶的角色。
您只需要將 CSS 類添加到要隱藏或顯示的 div 或 span 元素中。如下所解釋:
範例:
Login/Logout 狀態:
要向已登入用戶顯示元素/菜單項,請添加此 CSS 類: visible_to_logged_in 或 hidden_to_logged_out
要從已登入用戶隱藏元素/菜單項,請添加此 CSS 類: visible_to_logged_out 或 hidden_to_logged_in
對於用戶角色:
* 要向具有管理員角色的用戶顯示元素/菜單項,請添加此 CSS 類: visible_to_role_administrator 或 hidden_to_role_administrator
* 注意: 要僅顯示元素給多個特定角色,您需要為每個角色添加該元素。要從多個特定角色中隱藏單個元素/菜單項,您可以將多個 CSS 類添加到同一個元素中。
如果課程ID為123
要向上述課程訪問權限的用戶顯示元素/菜單項,請添加此 CSS 類: visible_to_course_123
要從上述課程訪問權限的用戶隱藏元素/菜單項,請添加此 CSS 類: hidden_to_course_123
要向已登入用戶顯示元素/菜單項,請添加此 CSS 類: visible_to_logged_in 或 hidden_to_logged_out
要從已登入用戶隱藏元素/菜單項,請添加此 CSS 類: visible_to_logged_out 或 hidden_to_logged_in
功能機制
多個 CSS 類: 如果添加了多個可見性控制類,則所有類都必須滿足標準才能保持元素可見。如果其中任何一個隱藏元素,元素將被隱藏。例如: visible_to_course_123 visible_to_course_124 只會顯示給那些有訪問兩個課程的人。
隱藏的數據/元素會到達瀏覽器。但用戶看不到它。
CSS 會為所有基於上述規則需要隱藏的 CSS 元素添加到頁面上。
加載頁面後,這些元素會使用 jQuery (如果可用) 從頁面中刪除,因此它在檢查中不會出現。
在頁面加載後呈現的元素會被隱藏,但不會從 DOM/頁面中刪除。
未來發展
根據此功能的興趣程度,我們將決定添加一個短代碼和/或可積木的區塊來實現此功能。
相關外掛
Visibility Control for LearnDash: 面向 LearnDash LMS 用戶的類似外掛。允許根據課程訪問和組訪問進行控制。同樣適用於 WooCommerce 用戶的類似外掛。
Visibility Control for WooCommerce: 允許根據用戶對特定 WooCommerce 產品或變體的購買進行控制
外掛標籤
開發者團隊
② 後台搜尋「Visibility Control for LearnPress」→ 直接安裝(推薦)
原文外掛簡介
Visibility Control for LearnPress helps you hide messages and content for specific criterion anywhere on your WordPress page.
You can show/hide HTML elements, menus, and other details based on:
1. User’s access to a particular LearnPress Course, Or
2. User is Logged In or Logged Out.
3. User’s role.
You simply need to add a CSS class to your element div or span. As explained here:
Example:
Login/Logout Status:
To show the element/menu item to a logged-in user, add this CSS class: visible_to_logged_in OR hidden_to_logged_out
To hide the element/menu item from a logged-in user, add this CSS class: visible_to_logged_out OR hidden_to_logged_in
For user’s role:
* To show the element/menu item to a user will role administrator, add this CSS class: visible_to_role_administrator OR hidden_to_role_administrator
* Note: To show an element to multiple specific roles only, you need add the element multiple times, one for each role. To hide an element/menu from specific multiple roles only you can add the element once add multiple classes to the same element.
If Course ID is 123
To show the element/menu item to user with access to above Course, add this CSS class: visible_to_course_123
To hide the element/menu item from user with access to above Course, add this CSS class: hidden_to_course_123
To show the element/menu item to a logged-in user, add this CSS class: visible_to_logged_in OR hidden_to_logged_out
To hide the element/menu item from a logged-in user, add this CSS class: visible_to_logged_out OR hidden_to_logged_in
For a course completion status, if Course ID is 123:
To show the element/menu item to user who completed above course, add this CSS class: visible_to_course_complete_123
To hide the element/menu item from user who completed above course, add this CSS class: hidden_to_course_complete_123
To show the element/menu item to user who has not completed above course, add this CSS class: visible_to_course_incomplete_123
To hide the element/menu item from user who has not completed above course, add this CSS class: hidden_to_course_incomplete_123
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_course_123 visible_to_course_124 will show the element only to those who have access to both courses.
Hidden data/elements reaches the browser. Though user’s do not see it.
CSS is added to the page for all CSS elements that needs to be hidden based on above rules.
After page is loaded. These elements are removed from page using jQuery (if available), so it won’t be available on Inspect.
Elements rendered after the page load are hidden but not removed from DOM/page.
Future Development
Depending on the interest in this feature, we will decide on adding a shortcode and/or a Gutenberg Block to achieve this feature.
Other Visibility Control Plugins:
– Visibility Control for LearnDash LMS
– Visibility Control for WP Courseware LMS
– Visibility Control for LifterLMS
– Visibility Control for TutorLMS
– Visibility Control for MasterStudyLMS
– Visibility Control for Sensei LMS
– Visibility Control for WooCommerce
Related Plugins for LearnPress:
– Experience API for LearnPress LMS
– Manual Completions for LearnPress LMS
