Select Page

Monthly Membership

This is your custom monthly membership page

function WPCW_units_getListOfUnitsWithDate( $user_id ,$moduleID ) { global $wpcwdb, $wpdb; $wpdb->show_errors(); // Current user $current_user = wp_get_current_user(); $SQL_USER_CONDITION = ""; if ( is_admin() && ! user_can( $current_user, 'manage_wpcw_settings' ) ) { $SQL_USER_CONDITION = $wpdb->prepare( ' AND unit_author = %d', $current_user->ID ); } $SQL = $wpdb->prepare( " SELECT u.*,p.unit_completed_date FROM $wpcwdb->units_meta as u LEFT JOIN $wpcwdb->user_progress as p ON u.unit_id= p.unit_id AND p.user_id=%d WHERE u.parent_module_id = %d $SQL_USER_CONDITION ORDER BY unit_order ASC, unit_id ASC ", $user_id ,$moduleID); // No list of associated IDs? Abort, and return false, as no units or unit objects. $rawUnits = $wpdb->get_results( $SQL ); if ( ! $rawUnits ) { return false; } // Turn list into ID => meta list $unitIDList = array(); foreach ( $rawUnits as $rawUnit ) { $unitIDList[ $rawUnit->unit_id ] = $rawUnit; } // Get list of IDs, and use this for WordPress query to get the full objects $uniPostObjsArgs = array( 'post_type' => 'course_unit', // Just course units 'number' => - 1, // No limit, i.e. all 'orderby' => 'none', // 'include' => array_keys( $unitIDList ) // List of posts to get. ); // Check permissions if ( is_admin() && ! user_can( $current_user, 'manage_wpcw_settings' ) ) { $uniPostObjsArgs['post_author'] = $current_user->ID; } // Get Units $unitPostObjsRaw = get_posts( $uniPostObjsArgs ); if ( ! $unitPostObjsRaw ) { return false; } // Re-order post objects so that they are ID => Object details, rather than 0 => Object, 1 => Object $unitPostObjs = array(); foreach ( $unitPostObjsRaw as $obj ) { // Add our metadata $obj->unit_meta = $unitIDList[ $obj->ID ]; $unitPostObjs[ $obj->ID ] = $obj; } // Use unit ordering from table to return actual ordering list. $unitDataRet = array(); foreach ( $unitIDList as $unitID => $unitObj ) { if ( isset( $unitPostObjs[ $unitID ] ) ) { $unitDataRet[ $unitID ] = $unitPostObjs[ $unitID ]; } } return $unitDataRet; } /* -------- code to disable or enable student report to corporate accounts------------------------*/ add_action('mpca_report_permission', 'mpca_report_permission', 10, 2); function mpca_report_permission($mepr_current_user) { global $wpdb; $row = $wpdb->get_results("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '".$wpdb->prefix."mepr_corporate_accounts' AND column_name = 'reportPermissions'" ); if(empty($row)){ $wpdb->query("ALTER TABLE ".$wpdb->prefix."mepr_corporate_accounts ADD `reportPermissions` int(1) DEFAULT 1 NOT NULL AFTER `uuid`"); } $id=json_decode($mepr_current_user)->ID; $SQL = "SELECT * FROM ".$wpdb->prefix."mepr_corporate_accounts where reportPermissions=0 AND user_id=".$id ; $user = $wpdb->get_results($SQL); $permissionCheck=count($user)>0?"checked":""; //echo '
Opt-out Student Weekly Report Email Notification

'; } add_action("wp_head","report_permission_script"); function report_permission_script(){ ?>