Created
June 20, 2013 15:20
-
-
Save joshfeck/5823688 to your computer and use it in GitHub Desktop.
Custom user profile form for the WP user integration add-on. Requirs WP user integration + Event Espresso.
This file contains 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 | |
//remove the group of fields that get updated on the user profile page | |
remove_action('personal_options_update', 'event_espresso_extra_profile_fields'); | |
remove_action('edit_user_profile_update', 'event_espresso_extra_profile_fields'); | |
//add a custom group of fields to be updated | |
add_action('personal_options_update', 'my_custom_event_espresso_extra_profile_fields'); | |
add_action('edit_user_profile_update', 'my_custom_event_espresso_extra_profile_fields'); | |
function my_custom_event_espresso_extra_profile_fields($user_id) { | |
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); | |
if (!current_user_can('edit_user', $user_id)) { | |
return false; | |
} | |
update_user_meta($user_id, 'event_espresso_address', sanitize_text_field($_POST['event_espresso_address'])); | |
update_user_meta($user_id, 'event_espresso_address2', sanitize_text_field($_POST['event_espresso_address2'])); | |
update_user_meta($user_id, 'event_espresso_city', sanitize_text_field($_POST['event_espresso_city'])); | |
update_user_meta($user_id, 'event_espresso_state', sanitize_text_field($_POST['event_espresso_state'])); | |
update_user_meta($user_id, 'event_espresso_zip', sanitize_text_field($_POST['event_espresso_zip'])); | |
// we don't update the country field, so it's been removed here) | |
update_user_meta($user_id, 'event_espresso_phone', sanitize_text_field($_POST['event_espresso_phone'])); | |
} | |
// remove the standard template | |
remove_action('show_user_profile', 'event_espresso_show_extra_profile_fields', 10); | |
remove_action('edit_user_profile', 'event_espresso_show_extra_profile_fields', 10); | |
// add the custom template that does not include the country field and adds a class for styling | |
add_action('show_user_profile', 'my_custom_event_espresso_show_extra_profile_fields', 10); | |
add_action('show_user_profile', 'my_custom_event_espresso_show_extra_profile_fields', 10); | |
function my_custom_event_espresso_show_extra_profile_fields($user) { | |
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); | |
global $espresso_premium; | |
if ($espresso_premium != true) | |
return; | |
?> | |
<h3><?php _e('Events Profile Information', 'event_espresso'); ?></h3> | |
<a name="event_espresso_profile" id="event_espresso_profile"></a> | |
<table class="form-table my-custom-profile-form"> <!-- add a class for styling --> | |
<tr> | |
<th><label for="event_espresso_address"><?php _e('Address/Street/Number', 'event_espresso'); ?></label></th> | |
<td> | |
<input type="text" name="event_espresso_address" id="event_espresso_address" value="<?php echo esc_attr(get_the_author_meta('event_espresso_address', $user->ID)); ?>" class="regular-text" /><br /> | |
<span class="description"><?php _e('Please enter your Address/Street/Number.', 'event_espresso'); ?></span> | |
</td> | |
</tr> | |
<tr> | |
<th><label for="event_espresso_address2"><?php _e('Address 2', 'event_espresso'); ?></label></th> | |
<td> | |
<input type="text" name="event_espresso_address2" id="event_espresso_address2" value="<?php echo esc_attr(get_the_author_meta('event_espresso_address2', $user->ID)); ?>" class="regular-text" /><br /> | |
<span class="description"><?php _e('Optional', 'event_espresso'); ?></span> | |
</td> | |
</tr> | |
<tr> | |
<th><label for="event_espresso_city"><?php _e('City/Town/Village', 'event_espresso'); ?></label></th> | |
<td> | |
<input type="text" name="event_espresso_city" id="event_espresso_city" value="<?php echo esc_attr(get_the_author_meta('event_espresso_city', $user->ID)); ?>" class="regular-text" /><br /> | |
<span class="description"><?php _e('Please enter your City/Town/Village.', 'event_espresso'); ?></span> | |
</td> | |
</tr> | |
<tr> | |
<th><label for="event_espresso_state"><?php _e('State/County/Province', 'event_espresso'); ?></label></th> | |
<td> | |
<input type="text" name="event_espresso_state" id="event_espresso_state" value="<?php echo esc_attr(get_the_author_meta('event_espresso_state', $user->ID)); ?>" class="regular-text" /><br /> | |
<span class="description"><?php _e('Please enter your State/County/Province.', 'event_espresso'); ?></span> | |
</td> | |
</tr> | |
<tr> | |
<th><label for="event_espresso_zip"><?php _e('Zip/Postal Code', 'event_espresso'); ?></label></th> | |
<td> | |
<input type="text" name="event_espresso_zip" id="event_espresso_zip" value="<?php echo esc_attr(get_the_author_meta('event_espresso_zip', $user->ID)); ?>" class="regular-text" /><br /> | |
<span class="description"><?php _e('Please enter your Zip/Postal Code.', 'event_espresso'); ?></span> | |
</td> | |
</tr> | |
<!-- removed country field here --> | |
<tr> | |
<th><label for="event_espresso_phone"><?php _e('Phone Number', 'event_espresso'); ?></label></th> | |
<td> | |
<input type="text" name="event_espresso_phone" id="event_espresso_phone" value="<?php echo esc_attr(get_the_author_meta('event_espresso_phone', $user->ID)); ?>" class="regular-text" /><br /> | |
<span class="description"><?php _e('Please enter your Phone Number.', 'event_espresso'); ?></span> | |
</td> | |
</tr> | |
</table> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment