do_action( 'personal_options_update', int $user_id )

Fires before the page loads on the ‘Profile’ editing screen.


Description Description

The action only fires if the current user is editing their own profile.


Top ↑

Parameters Parameters

$user_id

(int) The user ID.


Top ↑

More Information More Information

Generally, action hook is used to save custom fields that have been added to the WordPress profile page.

This hook only triggers when a user is viewing their own profile page. If you want to apply your hook to ALL profile pages (including users other than the current one), then you also need to use the edit_user_profile_update hook.


Top ↑

Source Source

File: wp-admin/user-edit.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Collins Mbaka

    This example shows how to save a custom field named ‘your_field’…

    add_action('personal_options_update', 'update_extra_profile_fields');
     
    function update_extra_profile_fields( $user_id ) {
        if ( current_user_can( 'edit_user', $user_id) ) {
            update_user_meta( $user_id, 'my_custom_field', sanitize_text_field( $_POST['your_field'] ) );
        }
    }
    
  2. Skip to note 2 content
    Contributed by Akira Tachibana

    (From Codex)
    This example shows how to save a custom field named ‘your_field’…

    add_action( 'personal_options_update', 'wporg_update_extra_profile_fields' );
     
     function wporg_update_extra_profile_fields( $user_id ) {
         if ( current_user_can( 'edit_user', $user_id ) )
             update_user_meta( $user_id, 'my_custom_field', $_POST['your_field'] );
     }

Top ↑

You must log in before being able to contribute a note or feedback.