<?php /** * Delete LearnDash related user data from scheduled cron * * @param int $user_id ID of a user */ function learndash_notifications_delete_learndash_user_data_cron() { $schedules = get_option( 'learndash_notifications_delete_user_data', array() ); foreach ( $schedules as $user_id => $args ) { delete_user_meta( $user_id, '_ld_notifications_last_login' ); $courses = $args['courses']; $groups = $args['groups']; foreach ( $courses as $course_id ) { delete_user_meta( $user_id, 'ld_sent_notification_enroll_course_' . $course_id ); $lessons = learndash_get_lesson_list( $course_id ); foreach ( $groups as $group_id ) { delete_user_meta( $user_id, 'ld_sent_notification_enroll_group_course_' . $course_id . '_' . $group_id ); } foreach ( $lessons as $lesson ) { delete_user_meta( $user_id, 'ld_sent_notification_lesson_available_' . $lesson->ID ); } } unset( $schedules[ $user_id ] ); } update_option( 'learndash_notifications_delete_user_data', $schedules ); } /** * Schedule cron delete user data in DB * * @param int $user_id User ID */ function learndash_notifications_schedule_delete_user_data( $user_id ) { $courses = ld_get_mycourses( $user_id ); $groups = learndash_get_groups( $id_only = true, $user_id ) ?: array(); $schedules = get_option( 'learndash_notifications_delete_user_data', array() ); $schedules[ $user_id ] = array( 'courses' => $courses, 'groups' => $groups, ); update_option( 'learndash_notifications_delete_user_data', $schedules ); } add_action( 'learndash_delete_user_data', 'learndash_notifications_schedule_delete_user_data' );
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
admin | Folder | 0755 |
|
|
activation.php | File | 426 B | 0644 |
|
ajax.php | File | 4.34 KB | 0644 |
|
class-dependency-check.php | File | 240 B | 0644 |
|
cron.php | File | 2.6 KB | 0644 |
|
database.php | File | 10.61 KB | 0644 |
|
deactivation.php | File | 304 B | 0644 |
|
functions.php | File | 1.82 KB | 0644 |
|
logger.php | File | 2.05 KB | 0644 |
|
meta-box.php | File | 31.46 KB | 0644 |
|
notification.php | File | 79.16 KB | 0644 |
|
post-type.php | File | 12.03 KB | 0644 |
|
shortcode.php | File | 12.09 KB | 0644 |
|
subscription-manager.php | File | 4.69 KB | 0644 |
|
tools.php | File | 4.2 KB | 0644 |
|
update.php | File | 1.25 KB | 0644 |
|
user.php | File | 1.61 KB | 0644 |
|