• Resolved kamarr

    (@kamarr)


    I’m having great success using this plugin, however I came across two problems when removing the contact info fields on the TML profile page. I’m not sure how to remove only part of the contact info fields without removing them all.

    It seams the contact info fields are grouped together in one block of code.

    <?php
    			foreach ( wp_get_user_contact_methods() as $name => $desc ) {
    		?>
    		<tr class="tml-user-contact-method-<?php echo $name; ?>-wrap">
    			<th><label for="<?php echo $name; ?>"><?php echo apply_filters( 'user_'.$name.'_label', $desc ); ?></label></th>
    			<td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
    		</tr>
    		<?php

    Since they are grouped under one block of code, I’m not sure what labels point to what.

    Example:
    I want to remove the social media, website and company name fields, while leaving the zip code, phone number, city, etc. fields.
    I’m sure the fix is simple, but how would I target, display and save those fields like I would the nickname field, which is coded as such;

    <tr class="tml-nickname-wrap">
    			<th><label for="nickname"><?php _e( 'Username', 'theme-my-login' ); ?></label></th>
    			<td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e( 'Usernames cannot be changed.', 'theme-my-login' ); ?></span></td>
    		</tr> 

    Thank you for your assistance.

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

    (@jfarthing84)

    The function wp_get_user_contact_methods() has a filter called user_contactmethods. You would filter them using that:

    
    function filter_user_contact_methods( $methods ) {
        $wanted_methods = array( 'city', 'state', 'zip' );
        foreach ( $methods as $method => $label ) {
            if ( ! isset( $wanted_methods[ $method ] ) ) {
                unset( $methods[ $method ] );
            }
        }
        return $methods;
    }
    add_filter( 'user_contactmethods', 'filter_user_contact_methods' );
    
    kamarr.cos

    (@kamarrcos)

    @jfarthing84 You are the man!!!

    Last question. How would I implement that into this block of code.

    
    <?php
    			foreach ( wp_get_user_contact_methods() as $name => $desc ) {
    			    
    		?>
    		
    		<tr class="tml-user-contact-method-<?php echo $name; ?>-wrap">
    			<th><label for="<?php echo $name; ?>"><?php echo apply_filters( 'user_'.$name.'_label', $desc ); ?></label></th>
    			<td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td>
    		</tr>
    		<?php
    			}
    		?>
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Profile page edit and save contact info.’ is closed to new replies.