WordPress.org

Ready to get started?Download WordPress

Forums

Theme My Login
[resolved] adding new fields? (5 posts)

  1. cybershot
    Member
    Posted 1 year ago #

    For the last hour, I have been following the instruction here

    http://www.jfarthing.com/development/theme-my-login/adding-extra-registration-fields/

    I have found that there is no theme-my-login-custom.php file that I can find anywhere in the plugin folder. So I made my own and put it in the plugin folder as the instructions say to do. Not in plugins/theme-my-login but just /plugins

    I am not sure if it is working. I see the new field in my registration form but once I get logged in, I do not see the field in the profile nor do I see the information in the profile. Do I now need to use the theme-my-profile to show this new data?

    http://wordpress.org/extend/plugins/theme-my-login/

  2. Jeff Farthing
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. p4004
    Member
    Posted 1 year ago #

    Why this hook is not documented at http://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.

  4. Jeff Farthing
    Member
    Plugin Author

    Posted 1 year ago #

    Because that hook is a WordPress hook.

  5. Imran ul Haque Ansari
    Member
    Posted 10 months ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic