public function process_alert(array &$to_notified) { $post_id = wskl_get_option('inactive-accounts_post_alert'); $shortcodes = WSKL()->submodules()->get_submodule('inactive-accounts')->shortcodes; foreach ($to_notified as $user) { wskl_set_user_alerted($user->ID, $this->cron_job_id); } WSKL_Inactive_Accounts_Email::send_email($to_notified, $post_id, $shortcodes); }
public function test() { if (!current_user_can('manage_options')) { die; } $active_span = wskl_get_option('inactive-accounts_active_span'); $alert = wskl_get_option('inactive-accounts_alert'); $target_roles = wskl_get_option('inactive-accounts_target_role'); if (!$active_span || !$alert || !$target_roles) { return; } $guests = array(get_user_by('login', 'guest'), get_user_by('login', 'guest2'), get_user_by('login', 'guest3')); if (is_array($target_roles)) { $target_role = $target_roles[0]; } else { $target_role = $target_roles; } foreach ($guests as $guest) { $guest->remove_role('wskl_deactivated'); $guest->add_role($target_role); } if (is_array($target_roles) && sizeof($target_roles) > 1) { $guests[1]->remove_role($target_role); $guests[1]->add_role($target_roles[1]); } $recent = time() - DAY_IN_SECONDS; $alert_ts = $recent - $active_span * DAY_IN_SECONDS + $alert * DAY_IN_SECONDS - DAY_IN_SECONDS; $deactivate_ts = $recent - $active_span * DAY_IN_SECONDS - MONTH_IN_SECONDS; error_log('Recent: ' . $recent); error_log('Alert: ' . $alert_ts); error_log('Deactivate: ' . $deactivate_ts); wskl_set_user_last_login($guests[0]->ID, $recent); wskl_set_user_last_login($guests[1]->ID, $alert_ts); wskl_set_user_last_login($guests[2]->ID, $deactivate_ts); wskl_delete_user_alerted($guests[1]->ID); wskl_set_user_alerted($guests[2]->ID, $alert_ts - WEEK_IN_SECONDS); wskl_load_module('/includes/inactive-accounts/class-wskl-inactive-accounts-cron-jobs.php'); $job = new WSKL_Inactive_Accounts_Cron_Jobs(); $job->fill_user_login_field(); $job->do_inactive_account_filtering(); die; }