Skip to content

Instantly share code, notes, and snippets.

@alexpos
Created December 23, 2013 07:04
Show Gist options
  • Save alexpos/8092774 to your computer and use it in GitHub Desktop.
Save alexpos/8092774 to your computer and use it in GitHub Desktop.

Revisions

  1. alexpos revised this gist Dec 23, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions contact_method.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    function modify_contact_methods($profile_fields) {

    // Add new fields
  2. alexpos revised this gist Dec 23, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions user_profile.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    add_action( 'personal_options_update', 'save_custom_profile_fields' );
    add_action( 'edit_user_profile_update', 'save_custom_profile_fields' );
    function save_custom_profile_fields( $user_id ) {
  3. alexpos revised this gist Dec 23, 2013. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  4. alexpos revised this gist Dec 23, 2013. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    function modify_contact_methods($profile_fields) {

    // Add new fields
    $profile_fields['twitter'] = 'Twitter Username';
    $profile_fields['facebook'] = 'Facebook URL';
    $profile_fields['gplus'] = 'Google+ URL';

    // Remove old fields
    unset($profile_fields['aim']);

    return $profile_fields;
    }
    add_filter('user_contactmethods', 'modify_contact_methods');
  5. alexpos created this gist Dec 23, 2013.
    21 changes: 21 additions & 0 deletions *scratch*.el
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    add_action( 'personal_options_update', 'save_custom_profile_fields' );
    add_action( 'edit_user_profile_update', 'save_custom_profile_fields' );
    function save_custom_profile_fields( $user_id ) {
    update_user_meta( $user_id, 'phone_number', $_POST['phone_number'], get_user_meta( $user_id, 'phone_number', true ) );
    update_user_meta( $user_id, 'greeting', $_POST['greeting'], get_user_meta( $user_id, 'greeting', true ) );
    }

    add_filter( 'user_contactmethods', 'add_contact_option', 10, 2 );
    function add_contact_option( $user_contactmethods, $user ) {
    $user_contactmethods['phone_number'] = 'Phone Number';
    return $user_contactmethods;
    }

    add_action( 'personal_options', 'add_profile_options');
    function add_profile_options( $profileuser ) {
    $greeting = get_user_meta($profileuser->ID, 'greeting', true);
    ?><tr>
    <th scope="row">Greeting</th>
    <td><input type="text" name="greeting" value="<?php echo $greeting; ?>" /></td>
    </tr><?php
    }