From 8d1d3301e8d7c2dff36c854c0a36460a8d6f9cc9 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 7 Sep 2018 15:32:28 -0400 Subject: [PATCH] Setup cron task and new cron. Setup a new cron task to check for and reset any contact roles for active members to own entity manager. --- models/admin/ajax/billingFixActiveUsers.php | 8 +++++--- setup/adminHooks.php | 22 ++++++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/models/admin/ajax/billingFixActiveUsers.php b/models/admin/ajax/billingFixActiveUsers.php index 4c7c613..32ab08e 100644 --- a/models/admin/ajax/billingFixActiveUsers.php +++ b/models/admin/ajax/billingFixActiveUsers.php @@ -70,7 +70,7 @@ class GlmMembersAdmin_ajax_billingFixActiveUsers public function modelAction( $actionData = false ) { - + $rolesReset = 0; // echo '
$actionData: ' . print_r( $actionData, true ) . '
'; $days_after_expired = $this->config['settings']['days_after_expired']; $current_date = date( 'Y-m-d' ); @@ -89,7 +89,7 @@ class GlmMembersAdmin_ajax_billingFixActiveUsers ARRAY_A ); $total = count( $members ); - echo '
$total: ' . print_r( $total, true ) . '
'; + // echo '
$total: ' . print_r( $total, true ) . '
'; if ( isset( $members ) && $members ) { foreach ( $members as $member ) { echo '
$member: ' . print_r( $member, true ) . '
'; @@ -98,9 +98,10 @@ class GlmMembersAdmin_ajax_billingFixActiveUsers $user_id = $Contact->getWpUserId( $contact_id ); $wpUser = get_user_by( 'id', $user_id ); if ( $wpUser ) { - echo '
$wpUser-role: ' . print_r( $wpUser->roles, true ) . '
'; + // echo '
$wpUser-role: ' . print_r( $wpUser->roles, true ) . '
'; $roles = $wpUser->roles; if ( $roles[0] != 'glm_members_own_entity_manager' ) { + $rolesReset++; apply_filters( 'glm_contact_update_user_role_by_ref_dest', '', @@ -113,6 +114,7 @@ class GlmMembersAdmin_ajax_billingFixActiveUsers } } + echo '
$rolesReset: ' . print_r( $rolesReset, true ) . '
'; } } diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 1b803f1..991d6a8 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -46,7 +46,7 @@ add_filter( array( 'menu' => 'ajax', 'action' => 'billingFlagExpiredUsers', - 'daysOfWeek' => range( 1, 7 ), + 'daysOfWeek' => false, 'times' => array( 5 ), 'params' => array() ) @@ -55,6 +55,22 @@ add_filter( } ); +add_filter( + 'glm_associate_cron_request', + function( $cron_task ){ + $new_cron = array( + array( + 'menu' => 'ajax', + 'action' => 'billingFixActiveUsers', + 'daysOfWeek' => false, + 'times' => array( 6 ), + 'params' => array() + ) + ); + return array_merge( $cron_task, $new_cron ); + } +); + /** * Setup cron task request to run billingSetupQueue * @@ -67,7 +83,7 @@ add_filter( array( 'menu' => 'ajax', 'action' => 'billingSetupQueue', - 'daysOfWeek' => range( 1, 7 ), + 'daysOfWeek' => false, 'times' => array( 3 ), 'params' => array() ) @@ -88,7 +104,7 @@ add_filter( array( 'menu' => 'ajax', 'action' => 'billingRunQueue', - 'daysOfWeek' => range( 1, 7 ), + 'daysOfWeek' => false, 'times' => array( 4 ), 'params' => array() ) -- 2.17.1