Changeset 3000299
- Timestamp:
- 11/22/2023 05:07:18 PM (17 months ago)
- Location:
- memberpress-addon-for-wp-courseware
- Files:
-
- 12 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
memberpress-addon-for-wp-courseware/trunk/includes/class-wpcw-mp-members.php
r2019574 r3000299 127 127 ); 128 128 129 if ( isset( $_REQUEST['action'] ) && 'retroactiveassignment' === $_REQUEST['action'] ) { 130 $level_ID = $levelDetails['id']; 131 $this->retroactive_assignment( $level_ID ); 132 133 return; 134 } 135 129 136 // Get a list of course IDs that exist. 130 137 $courses = wpcw_mp_addon_get_courses( false ); … … 149 156 $elem = new FormElement( 'retroactive_assignment', __( 'Do you want to retroactively assign these courses to current customers?', 'wpcw-mp-addon' ), true ); 150 157 $elem->setTypeAsRadioButtons( array( 151 'Yes' => __( 'Yes ', 'wpcw-mp-addon' ),152 'No' => __( 'No ', 'wpcw-mp-addon' ),158 'Yes' => __( 'Yes, enroll students into newly selected course(s)', 'wpcw-wc-addon' ), 159 'No' => __( 'No, just associate course(s) with the membership level.', 'wpcw-wc-addon' ), 153 160 ) ); 161 154 162 $form->addFormElement( $elem ); 155 163 … … 165 173 global $wpdb, $wpcwdb; 166 174 $wpdb->show_errors(); 175 176 $current_levelList = array(); 177 178 if ( $this->getCourseAccessListForLevel( $levelDetails['id'] ) ){ 179 $current_levelList = array_keys( $this->getCourseAccessListForLevel( $levelDetails['id'] ) ); 180 } 167 181 168 182 // Remove all previous level mappings (as some will have been removed). … … 193 207 if ( 'Yes' == $retroactive_assignment && count( $mapplingList ) >= 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName 194 208 $level_ID = $levelDetails['id']; // phpcs:ignore WordPress.NamingConventions.ValidVariableName 209 210 $new_levelList = array_keys( $mapplingList ); 211 $remove_courses = array_diff( $current_levelList, $new_levelList ); 212 $add_courses = array_diff( $new_levelList, $current_levelList ); 213 214 if ( $add_courses ){ 215 set_transient( 'wpcw_add_courses_' . $level_ID, $add_courses, 60*60*12 ); 216 } 217 218 if ( $remove_courses ){ 219 set_transient( 'wpcw_remove_courses_' . $level_ID, $remove_courses, 60*60*12 ); 220 } 221 195 222 $this->retroactive_assignment( $level_ID ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName 223 224 return; 196 225 // $page->showMessage(__('All members were successfully retroactively enrolled into the selected courses.', 'wpcw-mp-addon')); 197 226 } … … 273 302 // Show which courses will be added to users created at this level. 274 303 foreach ( $courses as $courseID => $courseName ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName 304 if ( ! isset($courseListInDB[ $courseID ]) ){ 305 continue; 306 } 275 307 $data['wpcw_members_levels'] .= sprintf( '<li class="wpcw_%s">%s</li>', ( isset( $courseListInDB[ $courseID ] ) ? 'enabled' : 'disabled' ), $courseName ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName 276 308 } -
memberpress-addon-for-wp-courseware/trunk/includes/class-wpcw-mp-membership.php
r2360462 r3000299 111 111 112 112 $mepr_db = new MeprDb(); 113 $page = new PageBuilder( false ); 113 114 $page = new PageBuilder( false ); 115 116 $batch = 50; 117 $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; 118 $count = isset( $_GET['count'] ) ? absint( $_GET['count'] ) : 0; 119 $steps = isset( $_GET['steps'] ) ? $_GET['steps'] : 'continue'; 120 121 $coursesToAdd = get_transient( 'wpcw_add_courses_' . $level_id ); 122 $coursesToRemove = get_transient( 'wpcw_remove_courses_' . $level_id ); 123 124 $summary_url = add_query_arg( array( 'page' => $this->extensionID ), admin_url( 'admin.php' ) ); 125 $course_url = add_query_arg( array( 'page' => $this->extensionID, 'level_id' => $level_id ), admin_url( 'admin.php' ) ); 126 127 if ( 'finished' === $steps ) { 128 $page->showMessage( 129 esc_html__( 'Course access settings successfully updated.', 'wpcw-wc-addon' ) 130 . '<br />' . 131 esc_html__( 'All existing customers were retroactively enrolled into the selected courses successfully.', 'wpcw-wc-addon' ) 132 . '<br /><br />' . 133 /* translators: %s - Summary Url. */ 134 sprintf( __( 'Want to return to the <a href="%s">Course Access Settings</a>?', 'wpcw-wc-addon' ), $summary_url ) 135 ); 136 137 printf( '<br /><a href="%s" class="button-primary">%s</a>', $course_url, __( '« Return to Course', 'wpcw-wc-addon' ) ); 138 139 if ( $coursesToRemove ){ 140 delete_transient( 'wpcw_remove_courses_' . $level_id ); 141 } 142 143 if ( $coursesToAdd ){ 144 delete_transient( 'wpcw_add_courses_' . $level_id ); 145 } 146 147 return; 148 } 149 150 if ( isset( $_POST['retroactive_assignment'] ) ) { 151 $step = 1; 152 $count = 0; 153 $steps = 'continue'; 154 } 114 155 115 156 // Get user's assigned products and enroll them into courses accordingly. 116 $ transations = $wpdb->get_results(157 $customers = $wpdb->get_results( 117 158 $wpdb->prepare( 118 159 "SELECT user_id, id 119 160 FROM {$mepr_db->transactions} 120 161 WHERE product_id = %d 121 AND (status = 'confirmed' OR status = 'complete')", 122 $level_id 123 ) 124 ); 125 126 if ( $transations ) { 127 foreach ( $transations as $transaction ) { 128 $user_id = $transaction->user_id; 129 $user = new MeprUser( $user_id ); 130 131 $product_subscriptions = $user->active_product_subscriptions( 'ids', true ); 132 133 $this->handle_courseSync( $user_id, $product_subscriptions ); 134 } 135 136 $page->showMessage( __( 'All members were retroactively enrolled into the selected courses successfully.', 'wpcw-mp-addon' ) ); 162 AND (status = 'confirmed' OR status = 'complete') 163 LIMIT %d 164 OFFSET %d", 165 $level_id, 166 $batch, 167 $count 168 ), ARRAY_A ); 169 170 if ( ! $customers && ! isset( $_GET['action'] ) ) { 171 $page->showMessage( esc_html__( 'No existing customers found for the specified product.', 'wpcw-wc-addon' ) ); 137 172 138 173 return; 139 } else { 140 $page->showMessage( __( 'No existing members found for the specified product.', 'wpcw-mp-addon' ) ); 141 } 174 } 175 176 if ( $customers && 'continue' === $steps ) { 177 if ( count( $customers ) < $batch ) { 178 $steps = 'finished'; 179 } 180 181 foreach ( $customers as $customer ) { 182 wpcw_log($customer); 183 $customer_id = $customer['user_id']; 184 $user = new MeprUser( $customer_id ); 185 186 if ( $coursesToRemove ){ 187 $products = array(); 188 $courseIDList = array(); 189 190 $product_subscriptions = $user->active_product_subscriptions( 'ids', true ); 191 192 foreach ( $product_subscriptions as $subscription ) { 193 // Got courses for this product. 194 $courses = $this->getCourseAccessListForLevel( $subscription ); 195 196 if ( $courses ) { 197 foreach ( $courses as $courseIDToKeep => $levelID ) { 198 $courseIDList[] = $courseIDToKeep; 199 } 200 } 201 } 202 203 $removeCourses = array_diff( $coursesToRemove, $courseIDList ); 204 205 // De-enroll students from specified courses 206 $this->handle_course_de_enrollment( $customer_id, $removeCourses ); 207 208 } 209 210 if ( $coursesToAdd ){ 211 // Enroll students into specified courses 212 WPCW_courses_syncUserAccess( $customer_id, $coursesToAdd, 'add' ); 213 } 214 // Increment Count. 215 $count += 1; 216 } 217 218 $step += 1; 219 } else { 220 $steps = 'finished'; 221 } 222 223 $page->showMessage( esc_html__( 'Please wait. Retroactively updating existing customers...', 'wpcw-wc-addon' ) ); 224 225 $location_url = add_query_arg( array( 226 'page' => $this->extensionID, 227 'level_id' => $level_id, 228 'step' => $step, 229 'count' => $count, 230 'steps' => $steps, 231 'action' => 'retroactiveassignment' 232 ), admin_url( 'admin.php' ) ); 233 234 ?> 235 <script type="text/javascript"> 236 setTimeout( function () { 237 document.location.href = "<?php echo $location_url; ?>"; 238 }, 1000 ); 239 </script> 240 <?php 142 241 } 143 242 … … 164 263 // Over to the parent class to handle the sync of data. 165 264 $this->handle_courseSync( $user_id, $product_subscriptions ); 265 } 266 267 /** 268 * Handle Course De-Enrollment. 269 * 270 * @since 1.5.0 271 * 272 * @param int $student_id The student id. 273 * @param array $course_ids The course ids to enroll. 274 */ 275 public function handle_course_de_enrollment( $student_id, $course_ids = array() ) { 276 global $wpdb, $wpcwdb; 277 278 if ( empty( $course_ids ) || ! is_array( $course_ids ) ) { 279 return; 280 } 281 282 $csv_course_ids = implode( ',', $course_ids ); 283 284 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpcwdb->user_courses} WHERE user_id = %d AND course_id IN ({$csv_course_ids})", $student_id ) ); // phpcs:ignore WordPress.DB 285 286 WPCW_queue_dripfeed::updateQueueItems_removeUser_fromCourseList( $student_id, $course_ids ); 166 287 } 167 288 -
memberpress-addon-for-wp-courseware/trunk/readme.txt
r2948951 r3000299 3 3 Donate link: https://flyplugins.com/donate 4 4 Tags: learning management system, selling online courses 5 Requires at least: 4.8 6 Tested up to: 6.2.2 7 Stable tag: 1.4.2 5 Requires at least: 4.9 6 Tested up to: 6.4.1 7 Stable tag: 2.0 8 Requires PHP: 5.2.4 8 9 License: GPLv3 9 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html 10 11 11 This plugin adds integration between MemberPress and WP Courseware which allows you to associate course sto products for automatic enrollment.12 This plugin adds integration between MemberPress and WP Courseware which allows you to associate course(s) to products for automatic enrollment. 12 13 13 14 == Description == … … 15 16 16 17 = Would you like to sell an online course with MemberPress? = 17 The MemberPress Addon for WP Courseware will add full integration with WP Courseware. Simply assign WP Courseware course s to a MemberPress product. When a student purchases the product, they will automatically be enrolled into the associated courses.18 The MemberPress Addon for WP Courseware will add full integration with WP Courseware. Simply assign WP Courseware course(s) to a MemberPress product. When a student purchases the product, they will automatically be enrolled into the associated course(s). 18 19 19 20 With this addon, you will be able to create a fully automated [Learning Management System](https://flyplugins.com/wp-courseware) and sell online courses. … … 23 24 24 25 = Basic Configuration Steps = 25 1. Create a course with WP Courseware and add module s, units, and quizzes26 1. Create a course with WP Courseware and add module(s), unit(s), and quiz(zes) 26 27 2. Create a course outline page using [shortcode] 27 28 3. Create a product and set a price 28 29 4. Associate one or more WP Courseware courses with the product 29 5. New student pays for the product, and WP Courseware enrolls them to the appropriate course sbased on the purchased product30 5. New student pays for the product, and WP Courseware enrolls them to the appropriate course(s) based on the purchased product 30 31 31 32 = Check out Fly Plugins = … … 76 77 == Changelog == 77 78 79 = 2.0 = 80 * New: Added ability to retoactively enroll a large quantity of students. 81 * New: Added new filter wpcw_mp_addon_can_load to allow enrollment method to be changed to "add" instead of "sync" 82 78 83 = 1.4.2 = 79 84 * Fix: Fixed issue where course list only displaying 20 courses -
memberpress-addon-for-wp-courseware/trunk/wp-courseware-memberpress.php
r2663782 r3000299 2 2 /** 3 3 * Plugin Name: WP Courseware - MemberPress Add On 4 * Version: 1.4.24 * Version: 2.0 5 5 * Plugin URI: http://flyplugins.com 6 6 * Description: The official extension for WP Courseware to add support for the MemberPress membership plugin for WordPress. … … 19 19 20 20 // Constants. 21 define( 'WPCW_MP_ADDON_VERSION', '1. 4.2' );21 define( 'WPCW_MP_ADDON_VERSION', '1.5.0' ); 22 22 23 23 /** 24 24 * WP Courseware Memberpress Addon. 25 25 * 26 * @since 1. 4.026 * @since 1.5.0 27 27 */ 28 28 function _wpcw_mp_addon() {
Note: See TracChangeset
for help on using the changeset viewer.