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' );
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 theedit_user_profile
hook (and possiblyshow_user_profile
, if you want users to be able to edit their own custom profile information).