adding new fields/infos to the user profile - action hooks... (5 posts)

  1. tooltonic
    Posted 9 years ago #


    i hope someone can help me. i am trying to build a plugin for my wordpress users. i want to
    add some fields and options in the users profile which you can find in the administration: 'Users' -> 'Your Profile'.
    here i want to add fields like birthday, picture-upload, etc. i put the fields with the help of the
    add_action('show_user_profile', 'do_something') function into the profile page, but i dont know how to put the user data into the database.
    i searched in several functions of wordpress for a possibility to process the user data. in wp-adminuser-edit.php the user data will be processed.
    there it calls a method named 'edit_user()' (wp-adminadmin-functions.php) and this one calls 'wp_update_user()' in registration-functions.php.
    i don
    t if it is possible to add new infos to the user profiles this way. thanx for all answers...


  2. jaredquinn
    Posted 9 years ago #

    You could try:

    update_usermeta( $user_id, 'field-name', $value);

    To update the usermeta data, and get_usermeta to retreive it.

  3. tooltonic
    Posted 9 years ago #

    thanx for the answer - it seems to work - but i have some problems: in the 'wp_usermeta' mysql-table it creates an entry with the meta_key i used, but i cannot print or load any of the posted data of my form-field. $_POST[] is empty at this point. also i cannot get the $user_id in my function. wordpress put out my plugin in user_edit.php - in page 'Your Profil' after the normal fields in the end of the form.


    function do_something() {
    echo '<input type="text" name="test" size="95">';
    update_usermeta( 1, 'new_meta', $test);

    add_action('show_user_profile', 'do_something');

  4. tooltonic
    Posted 9 years ago #

    ok - i found the error - i called the function 'update_usermeta()' at the wrong place (see code below for the correction). To work with the function 'update_usermeta()' - i have to include another page of functions, because i get an error message that a function 'get_userdata()' is not defined:

    'Fatal error: Call to undefined function get_userdata() in C:\htdocs\wordpress\wp-includes\functions.php on line 2238'.

    So i decide to include the missing file (pluggable-functions.php) with 'require_once()' and hope that it works in the future?!

    function add_fields() {
    echo '<input type="text" name="test" size="95">';

    add_action('show_user_profile', 'add_fields');

    if(...) {

    update_usermeta($_POST[checkuser_id], 'test', $_POST[test]);


  5. lyonnais69
    Posted 9 years ago #


    As it seems to work now, is it possible to get the whole code of your plugin ?
    I want to exactly do the same and since I've never done any plugin, it will help me.


Topic Closed

This topic has been closed to new replies.

About this Topic