1

I'm using the Theme my Login plugin for a client project and I'm having trouble updating profile fields once a user has been registered;

I followed the instructions here but they didn't seem to have any effect. If anyone could shed some light on it that would be great.

This is my current code;

register-form.php

<p>
    <input
      type="text"
      name="phone_number" 
      id="phone_number<?php $template->the_instance(); ?>" 
      class="input" 
      value="<?php $template->the_posted_value( 'phone_number' ); ?>" 
      size="20" 
      tabindex="20" 
      placeholder="Phone Number"
    />
</p>

profile-form.php

<p>
    <input 
      type="text" 
      name="phone_number" 
      id="phone_number" 
      value="<?php echo esc_attr( $profileuser->phone_number ); ?>" 
      class="regular-text" 
      placeholder="Phone Number"
    />
</p>

theme-my-login-custom.php

function tml_user_register( $user_id ) {
        // Phone Number
        if ( !empty( $_POST['phone_number'] ) )
            update_user_meta( $user_id, 'phone_number', $_POST['phone_number'] );
}
add_action( 'user_register', 'tml_user_register' );
  • Have you checked to see if the user meta-information (ie, phone number) is going into the database? – Pat J Jun 4 '13 at 19:57
  • Yes. Once someone registers, all of their information is there in their profile, but if I want to try and edit that information (To change the phone number for example) it doesn't work – Poisontonomes Jun 4 '13 at 20:11
  • OK. See my answer below. – Pat J Jun 4 '13 at 20:21
1

The user_register hook only fires when the user first registers. To have the custom profile data show up on the Edit User screen, you should use the edit_user_profile hook (and possibly show_user_profile, if you want users to be able to edit their own custom profile information).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.