Support » Fixing WordPress » Update Description via PHP

  • Resolved aehernandez

    (@aehernandez)


    Hi!

    I want to update the description of the user profile via PHP and send it to the database on user registration. Is there a way I can work around this?

    I’ve tried the following:

    add_action( 'user_register', 'expertopyme_update', 10, 1 );
    
    function expertopyme_update( $user_id ) {
        $user = get_userdata( $user_id );
        $interes =  $user->ep_interes;
    	update_user_meta( $user_id, 'description', $interes );
    }

    (I’m sorry, I’m really new to developing for wordpress)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Priyanka Behera

    (@priyankabehera155)

    Hi @aehernandez

    You can use the below function to update the descriptions.

    wp_update_user( array( ‘ID’ => $user_id, ‘user_url’ => $website ) );

    Thank you for your help, @priyankabehera155!

    Is there an specific action where it should be included to update the description on registration?

    • This reply was modified 8 months, 2 weeks ago by  aehernandez.

    Nevermind, @priyankabehera155. Thank you for your help!

    Managed to do it like this:

    
    add_action( 'user_register', 'my_save_extra_fields', 10, 1 );
    
    function my_save_extra_fields( $user_id ) {
       $user = get_userdata( $user_id );
       $interes =  $user->ep_interes;
       $user_data = wp_update_user( array( 'ID' => $user_id, 'description' => $interes ) );
        if ( isset( $_POST['description'] ) )
            update_user_meta($user_id, 'description', $_POST['description']);
    
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Update Description via PHP’ is closed to new replies.