Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'check_user_valid_cron_hook', 'check_user_valid_func' );
- if ( ! wp_next_scheduled( 'check_user_valid_cron_hook' ) ) {
- wp_schedule_event( time(), 'daily', 'check_user_valid_cron_hook' );
- }
- function check_user_valid_func() {
- // The Query
- $user_query = new WP_User_Query( array( 'role' => 'Purchaser', 'fields' => 'all' ) );
- $today = date("U");
- // User Loop
- if ( ! empty( $user_query->get_results() ) ) {
- foreach ( $user_query->get_results() as $user ) {
- $validuntil = types_render_usermeta( "date-of-home-purchase", array( "user_id" => "$user->ID", "output" => "raw" ) );
- $user_id = $user->ID;
- if($validuntil < $today) {
- $user = get_userdata( $user_id );
- $user->user_email;
- $message = '
- <html>
- <head>
- <title>Email title</title>
- </head>
- <body>
- <p>Some text</p>
- </body>
- </html>
- ';
- wp_mail( $user, 'Your subject', $message, $headers, $attachments );
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment