Last active
October 23, 2025 13:09
-
-
Save dparker1005/e91ee6938e1130f7af9edacd43152db2 to your computer and use it in GitHub Desktop.
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 | |
| // Copy from below here... | |
| /* | |
| Add birthday to user signup. | |
| For PayPal Express, uncomment line 58 | |
| */ | |
| // add birthday fields. | |
| function my_pmpro_birthday_checkout_after_email() | |
| { | |
| $current_day = date("j"); | |
| $current_month = date("M"); | |
| $current_year = date("Y"); | |
| ?> | |
| <div> | |
| <label for="birthday_month">Birthday</label> | |
| <select name="birthday_month"> | |
| <?php | |
| for($i = 1; $i < 13; $i++) | |
| { | |
| ?> | |
| <option value="<?php echo $i?>" <?php if(!empty($_REQUEST['birthday_month']) && $i == $_REQUEST['birthday_month']) { ?>selected="selected"<?php } ?>><?php echo date("M", strtotime($i . "/15/" . $current_year))?></option> | |
| <?php | |
| } | |
| ?> | |
| </select> | |
| <input type="text" name="birthday_day" size="4" placeholder="day" value="<?php if(!empty($_REQUEST['birthday_day'])) echo intval($_REQUEST['birthday_day']);?>" /> | |
| <input type="text" name="birthday_year" size="8" placeholder="year" value="<?php if(!empty($_REQUEST['birthday_year'])) echo intval($_REQUEST['birthday_year']);?>" /> | |
| <small>month/dd/yyyy</small> | |
| </div> | |
| <?php | |
| } | |
| add_action("pmpro_checkout_boxes", "my_pmpro_birthday_checkout_after_email"); | |
| //checking birthday | |
| function my_pmpro_birthday_registration_checks($okay) | |
| { | |
| if(!$okay) | |
| return $okay; //there are other errors to handle | |
| global $pmpro_msg, $pmpro_msgt; | |
| $birthday_month = intval($_REQUEST['birthday_month']); | |
| $birthday_day = intval($_REQUEST['birthday_day']); | |
| $birthday_year = intval($_REQUEST['birthday_year']); | |
| //make sure they entered any birthday | |
| if(empty($birthday_month) || empty($birthday_day) || empty($birthday_year)) | |
| { | |
| $pmpro_msg = "Please enter a birthday."; | |
| $pmpro_msgt = "pmpro_error"; | |
| return false; | |
| } else { | |
| // Un-comment line below for PayPal Express | |
| // $_SESSION['birthday'] = $birthday_year . "-" . $birthday_month . "-" . $birthday_day; | |
| } | |
| return $okay; | |
| } | |
| add_filter("pmpro_registration_checks", "my_pmpro_birthday_registration_checks"); | |
| //saving birthday | |
| function my_pmpro_birthday_after_checkout($user_id) | |
| { | |
| if( isset( $_SESSION['birthday'] ) ) { | |
| update_user_meta($user_id, "birthday", $_SESSION['birthday']); | |
| } else if(!empty($_REQUEST['birthday_month'])) { | |
| $birthday_month = intval($_REQUEST['birthday_month']); | |
| $birthday_day = intval($_REQUEST['birthday_day']); | |
| $birthday_year = intval($_REQUEST['birthday_year']); | |
| //save birthday | |
| $birthday = $birthday_year . "-" . $birthday_month . "-" . $birthday_day; | |
| update_user_meta($user_id, "birthday", $birthday); | |
| } | |
| } | |
| add_action("pmpro_after_checkout", "my_pmpro_birthday_after_checkout"); | |
| // Add birthday to members list | |
| function my_pmpro_members_list_heading_birthday( $columns ) { | |
| $columns['birthday'] = 'Birthday'; | |
| return $columns; | |
| } | |
| add_filter( 'pmpro_memberslist_extra_cols', 'my_pmpro_members_list_heading_birthday' ); | |
| function my_pmpro_members_list_user_birthday( $user ) { | |
| $birthday = get_user_meta( $user->ID, 'birthday', true ); | |
| if ( ! empty( $birthday ) ) { | |
| $dateformatstring = get_option( 'date_format' ); | |
| $user->birthday = date_i18n( $dateformatstring, strtotime( $birthday ) ); | |
| } else { | |
| $user->birthday = ''; | |
| } | |
| return $user; | |
| } | |
| add_filter( 'pmpro_members_list_user', 'my_pmpro_members_list_user_birthday' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment