Last active
August 29, 2015 14:14
-
-
Save amdrew/0bf426db10668a971faa to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Add twitter field to EDD Register form and save it to usermeta
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
/** | |
* Add new twitter field to EDD register form | |
*/ | |
function sumobi_edd_add_registration_field() { | |
?> | |
<p> | |
<label for="edd-user-twitter-username"><?php _e( 'Twitter Username', 'edd' ); ?></label> | |
<input id="edd-user-twitter-username" class="edd-input" type="text" name="edd_user_twitter_username" /> | |
</p> | |
<?php | |
} | |
add_action( 'edd_register_form_fields_before_submit', 'sumobi_edd_add_registration_field' ); | |
/** | |
* Insert twitter username into usermeta | |
* Will store into a metakey called twitter_username | |
*/ | |
function sumobi_edd_insert_user_data( $user_id, $user_data ) { | |
$twitter_username = isset( $_POST['edd_user_twitter_username'] ) ? sanitize_text_field( $_POST['edd_user_twitter_username'] ) : ''; | |
if ( $twitter_username ) { | |
update_user_meta( $user_id, 'twitter_username', $twitter_username ); | |
} | |
} | |
add_action( 'edd_insert_user', 'sumobi_edd_insert_user_data', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment