How to use the function wp_get_user_contact_methods() has a filter.
-
@jfarthing84
The functionwp_get_user_contact_methods()
has a filter called user_contactmethods.` You would filter them using that:unction 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' );
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 } ?>
- The topic ‘How to use the function wp_get_user_contact_methods() has a filter.’ is closed to new replies.