Created
December 16, 2020 03:50
-
-
Save wplit/6f263523da9131ca81b8c1bc42abafc0 to your computer and use it in GitHub Desktop.
user registration date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if ( function_exists( 'oxygen_vsb_register_condition' ) ) { | |
| oxygen_vsb_register_condition( | |
| 'User Registration', | |
| array('custom' => true, 'placeholder' => 'MM/DD/YYYY'), | |
| array( | |
| '==', | |
| 'is after', | |
| 'is before', | |
| '== (month)', | |
| 'is after (month)', | |
| 'is before (month)', | |
| ), | |
| 'user_registration_date_callback', | |
| 'User' | |
| ); | |
| } | |
| function user_registration_date_callback( $value, $operator ) { | |
| $user_info = wp_get_current_user(); | |
| $registered_time = strtotime($user_info->user_registered); | |
| $registered_time_month = strtotime(date('Y-m-01', $registered_time)); | |
| $date = strtotime($value); | |
| $date_month = strtotime(date('Y-m-01', $date)); | |
| if ($date === false) { | |
| return false; | |
| } | |
| $diff = $registered_time - $date; | |
| $diff = round($diff / (60 * 60 * 24)); | |
| $month_diff = $registered_time_month - $date_month; | |
| $month_diff = round($month_diff / (60 * 60 * 24)); | |
| if ($operator == '==') { | |
| return ($diff == 0); | |
| } | |
| elseif($operator == 'is after') { | |
| return ($diff > 0); | |
| } | |
| elseif($operator == 'is before') { | |
| return ($diff < 0); | |
| } | |
| elseif ($operator == '== (month)') { | |
| return ($month_diff == 0); | |
| } | |
| elseif($operator == 'is after (month)') { | |
| return ($month_diff > 0); | |
| } | |
| else { | |
| return ($month_diff < 0); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment