Menu Close

    WordPress Custom Fields User Profile Page

    WordPress Add Custom Fields User Edit Profile Page – In this post we see how we can add custom fields to user profile edit page in WordPress at admin end. When admin wants to add some extra information for the users in his/her site, then custom fields can play important role.

    As we know, WordPress provides hooks for almost every other feature/functionality so that we can update or manipulate according to our need. So for this also we’ll use some hooks to fulfill our post purpose.

    Let’s start with the code –

    *  @param $user
    *  @author Webkul
    add_action( 'edit_user_profile', 'wk_custom_user_profile_fields' );
    function wk_custom_user_profile_fields( $user )
        echo '<h3 class="heading">Custom Fields</h3>';
        <table class="form-table">
                <th><label for="contact">Contact</label></th>
    	    <td><input type="text" class="input-text form-control" name="contact" id="contact" />

    In above code, we add action to hook ‘edit_user_profile’ and create one input field in callback function. This function will display field when you are editing other user profile. If you want to show created fields for all profiles then use ‘show_user_profile’ hook and add action for same callback function.

    add_action( 'show_user_profile', 'wk_custom_user_profile_fields' );

    After executing above code, custom field will display on user profile edit page as below –

    Start your headless eCommerce
    Read More

    WordPress Custom Fields User Profile Page

    Now, to save the data for created custom fields we’ll use ‘edit_user_profile_update’ hook.

    add_action( 'edit_user_profile_update', 'wk_save_custom_user_profile_fields' );
    *   @param User Id $user_id
    function wk_save_custom_user_profile_fields( $user_id )
        $custom_data = $_POST['contact'];
        update_user_meta( $user_id, 'contact', $custom_data );

    The hook used above ‘edit_user_profile_update’ only triggers when user editing other user profile in the same way we mentioned above for displaying the fields. To save data for all user profiles, then you also need to use ‘personal_options_update’ hook.

    Reference –

    1 –

    2 –


    Still have any issue feel free to add a ticket and let us know your views to make the code better

    Thanks for Your Time! Have a Good Day!

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*

    Be the first to comment.

    Back to Top

    Table of Content