-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.php
More file actions
30 lines (26 loc) · 823 Bytes
/
demo.php
File metadata and controls
30 lines (26 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/**
* Daily checking of users role
*/
// cron for changing roles of cutomers to wholesalers
if (! wp_next_scheduled('vino_change_role_to_engros') ) {
wp_schedule_event(time(), 'daily', 'vino_change_role_to_engros');
}
add_action('vino_change_role_to_engros', 'Vino_change_role_to_engros_function');
/**
* Change role to Wholesler
*/
function Vino_Change_Role_To_Engros_Function()
{
$user_query = new WP_User_Query(array( 'role' => 'Customer' ));
if (! empty($user_query->get_results()) ) {
foreach ( $user_query->get_results() as $user ) {
$customer_role = get_field('customer_role', 'user_'.$user->ID);
if ($customer_role == 'engros') {
$user->remove_role('customer');
$user->add_role('engros');
}
}
}
}
?>