Results 1 to 1 of 1

Thread: Hook edit_user_profile_update doesn't work

  1. #1
    Thread Starter
    Rookie fanchrobin's Avatar
    Join Date
    May 2012
    Location
    France
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hook edit_user_profile_update doesn't work

    Hello,

    I have a problem with an additional function I tried to set up.
    (I'm using a child theme)

    1. I have added some registration fields to the registration form via the hook show_user_profile.
    Minor problem : I have had to add the code directly into the edit-profile.php, because it doesn't work when added in functions.php

    2. Registration works fine, additional user datas are added into the user meta table.

    3. Now I need to give the user the possibility to update his profile, including the additional metas... and I can't figure it out. Here the code I use (I tried to add it to functions.php and in edit-profile.php) :

    PHP Code:
    /*function at_custom_fields_update( $user_id, $password = "", $meta = array() ) {
     
        if ( !current_user_can( 'edit_user', $user_id ) )
            return false;
     
        // updatable fields
        $fields = array(
            'at_name',
            'at_firstname',
            'at_gender',
            'at_nationality',
            'at_livinglocation',
            'at_livinglocationbefore',
            'at_yearofbirth',
            'at_familytype',
            'at_childrentype',
            'at_retired',
        );
     
        foreach ( $fields as $field ) {
            $value = stripslashes( trim( $_POST[$field] ) ) ;
            $prev_value = get_user_meta( $user_id, $field, true );
            if ( ! empty( $value ) ) {
                update_user_meta( $user_id, $field, $value, $prev_value );
            }
        }
     
    }

    // custom fields update
    add_action( 'edit_user_profile_update', 'at_custom_fields_update' ); // Don't work on the frontend !
    add_action( 'personal_options_update', 'at_custom_fields_update' ); // Don't work on the frontend !
    */ 
    and here is an exemple of a field in the form

    HTML Code:
    <input class="text" size="40" type="text" name="at_yearofbirth" id="at_yearofbirth" value=<?php if (isset($_POST['at_yearofbirth'])) { echo esc_attr($_POST['at_yearofbirth']); } else { echo get_user_meta( $user_id, 'at_yearofbirth', true ) ; } ?>>
    Any help would be HIGHLY appreciated ! Thanks in advance.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Samcy Prune Ads Doesn't Work
    By graham in forum Report ClassiPress Bugs
    Replies: 10
    Last Post: November 14th, 2013, 06:18 PM
  2. [SOLVED] Map doesn't work with ver 1.2
    By archersoftech in forum Report Vantage Bugs (Legacy)
    Replies: 2
    Last Post: May 22nd, 2013, 07:47 PM
  3. [SOLVED] Doesn't work?
    By megamind in forum GeoReg
    Replies: 3
    Last Post: February 3rd, 2013, 11:38 PM
  4. [SOLVED] Ad count doesn't work
    By verified in forum Report ClassiPress Bugs
    Replies: 6
    Last Post: October 24th, 2011, 05:44 AM
  5. add-new doesn't work
    By piplo in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: May 19th, 2011, 02:07 AM