Changeset 2671549
- Timestamp:
- 02/02/2022 05:58:52 PM (4 years ago)
- Location:
- unenroll-for-learndash/trunk
- Files:
-
- 5 edited
-
admin/trun-settings.php (modified) (1 diff)
-
assets/js/trun.js (modified) (2 diffs)
-
includes/functions.php (modified) (2 diffs)
-
learndash-unenroll.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
unenroll-for-learndash/trunk/admin/trun-settings.php
r2586221 r2671549 62 62 'default' => 'none', 63 63 'description'=> __('Select where to place the \'Unenroll\' button on the grid', 'learndash-unenroll'), 64 'obs' => '',64 'obs' => __('Be aware that the \'Unenroll\' button will be placed on the grid only when the grid shortcode [ld_course_list] is used. If you plan to use the new Course Grid Block feature, the \'Unenroll\' button will not be displayed on the grid, leaving you with the option to show the button on the single course page.', 'learndash-unenroll'), 65 65 'final' => '', 66 66 'order' => 4, -
unenroll-for-learndash/trunk/assets/js/trun.js
r2586221 r2671549 14 14 const errorAlertTitle = trun_js_object.errorAlertTitle; 15 15 const errorAlertText = trun_js_object.errorAlertText; 16 const errorAlertAdminText = trun_js_object.errorAlertAdminText; 16 17 const alertReloadButton = trun_js_object.alertReloadButton; 17 18 const cancelAlertTextGroup = trun_js_object.cancelAlertTextGroup; … … 107 108 responseText = errorAlertText; 108 109 responseType = 'warning'; 110 //check if response has 'admin' substring in it 111 if(response.indexOf('admin') > -1) { 112 responseText = errorAlertAdminText; 113 } 109 114 } 110 115 console.log(response); -
unenroll-for-learndash/trunk/includes/functions.php
r2586221 r2671549 39 39 } 40 40 41 $user_id = get_current_user_id(); 41 //get current user 42 $user = wp_get_current_user(); 43 $user_id = $user->ID; 44 //check if has admin role 45 $admin_roles = array( 46 'administrator' 47 ); 48 $has_admin_role = array_intersect($admin_roles, $user->roles ); 49 50 if($has_admin_role) { 51 wp_die('Error: admin'); 52 } 42 53 43 54 $user_groups = ( !empty($_POST['userGroups']) && is_array($_POST['userGroups']) ) ? (array)$_POST['userGroups'] : []; … … 49 60 } 50 61 51 //User still has access. Course must be part of a group62 //User still has access. Course must be admin or part of a group 52 63 if(empty($user_groups)) { 53 64 //very strange...that should not happen -
unenroll-for-learndash/trunk/learndash-unenroll.php
r2586221 r2671549 6 6 * Author: Luis Rock 7 7 * Author URI: https://wptrat.com/ 8 * Version: 1.0. 08 * Version: 1.0.1 9 9 * Text Domain: learndash-unenroll 10 10 * Domain Path: /languages … … 81 81 /* translators: Text for the (maybe) error alert box */ 82 82 'errorAlertText' => esc_html__( 'We could not check the result.', 'learndash-unenroll' ), 83 /* translators: Text for when an admin is trying to enroll from a course (which is impossible) */ 84 'errorAlertAdminText' => esc_html__( 'You are a site admin, so you cannot unenroll.', 'learndash-unenroll' ), 83 85 /* translators: Text for the alert box reload button */ 84 86 'alertReloadButton' => esc_html__( 'Reload', 'learndash-unenroll' ), -
unenroll-for-learndash/trunk/readme.txt
r2586221 r2671549 5 5 Tested up to: 5.8 6 6 Requires PHP: 5.6 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GNU General Public License v3.0 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 52 52 53 53 == Changelog == 54 = 1.0.1 = 55 * Added: alert that site admin user cannot unenroll 56 * Added: inform on the settings page that the 'Unenroll' button will be placed on the grid only when the grid shortcode [ld_course_list] is used (no support for the new Course Grid Block feature). 57 54 58 = 1.0.0 = 55 59 * Initial Release.
Note: See TracChangeset
for help on using the changeset viewer.