Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    As I mentioned in the other post, there is a different hook that needs to be used to get the data in the profile. That hook is edit_user_profile.

    Add something like this to theme-my-login-custom.php:

    function tml_edit_user_profile( $profileuser ) {
    	?>
    	<p>
    		<label for="phone_number">Phone Number</label>
    		<input id="phone_number" type="text" name="phone_number" value="<?php echo $profileuser->phone_number; ?>" />
    	</p>
    	<?php
    }
    add_action( 'edit_user_profile', 'tml_edit_user_profile' );

    Of course, you would edit it to suit your needs, but that’s the general idea. This approach will add the fields to TML’s Themed Profiles, as well as to WP’s default profiles.

    Why this hook is not documented at https://www.jfarthing.com/development/theme-my-login/ ? I was looking for it for an hour until I found it here.

    Your plugin is great, but lack of documentation makes customizing it a bit difficult.

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Because that hook is a WordPress hook.

    I have added the phone number field in my registration form.
    i just copy theme-my-login\templates\register-form.php file in my theme folder and added this code below the email field

    <p>
    <label for="user_phone<?php $template->the_instance(); ?>"><?php _e('Phone'); ?></label>
    <input type="text" name="user_phone" id="user_phone<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value('user_phone'); ?>" size="20" />
    </p>

    and add this code in my function.php

    function tml_edit_user_profile( $profileuser ) { ?>
    <p>
    <label for="user_phone">Phone Number</label>
    <input id="user_phone" type="text" name="user_phone" value="<?php echo $profileuser->user_phone; ?>" />
    </p>
    <?php
    }
    add_action( 'edit_user_profile', 'tml_edit_user_profile' );
    
    function tml_user_register( $user_id ) {
    	if ( !empty( $_POST['user_phone'] ) )
    		update_user_meta( $user_id, 'user_phone', $_POST['user_phone'] );
    }
    add_action( 'user_register', 'tml_user_register' );

    This code is working on my site.

    and thanks Jeff for such a good plugin,it is easy to customize.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Theme My Login] adding new fields?’ is closed to new replies.