kamarr.cos
Forum Replies Created
-
@dualcube,
Thank you for your speedy reply!Moumita Thank you for your speedy reply.
I have checked the issue against the twenty seventeen theme which produced a similar issue. The sidebar was missing with twenty seventeen and with the current theme it displays at the bottom.
How would you suggest fixing this?
@dualcube
I am having a similar issue.- This reply was modified 7 years, 11 months ago by kamarr.cos.
Thank you @jfarthing84 and @tacov, your both amazing!
Just to test the method I started with. What would be the proper way to var_dump() the function.
How would that look when properly implemented.Thank you!!! @tacov you are the greatest.
Using
$keys = array_keys($user_contact); $user_contact = array_combine($keys,$keys); return $user_contact;
I was able to find the proper pointers and have successfully moved the unwanted fields using the
unset( $user_contact['twitter'] );
function.Update:
I’ve tried removing the
'twitter'
field that was created with the function,$user_contact['twitter'] = __( 'Twitter Username' );
By using
unset( $user_contact['twitter'] );
which was successful.
I’ve tried pointing to the original fields with no success. Maybe I’m not using the proper pointer. What would be the proper way to remove the facebook, twitter, google id, pinterest, and company name, or remove the original contact method fields and use the
$user_contact['twitter'] = __( 'Twitter Username' );
to add any and all desired fields.
After inserting the empty function.
function test_but_do_nothing( $the_methods ) { return $the_methods; } add_filter( 'user_contactmethods', 'test_but_do_nothing' );
The default methods still appear.
After inserting the example from the codex.
function modify_user_contact_methods( $user_contact ) { // Add user contact methods $user_contact['skype'] = __( 'Skype Username' ); $user_contact['twitter'] = __( 'Twitter Username' ); // Remove user contact methods unset( $user_contact['aim'] ); unset( $user_contact['jabber'] ); return $user_contact; } add_filter( 'user_contactmethods', 'modify_user_contact_methods' );
The original fields remain in addition to the two new fields Twitter and Skype.
P.S. I’ve tried changing the unset line of code to point to facebook and pintrest, however it won’t remove the fields.
- This reply was modified 7 years, 11 months ago by kamarr.cos.
- This reply was modified 7 years, 11 months ago by kamarr.cos.
With exceptions to the the TML original 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 } ?>
I’ve removed the snippet of code and all the contact methods reappear.
I’ve also searched the code to confirm there where no other pieces of code hooking into
user_contactmethods
.@taco
After insertingvar_dump($methods);die();
to the top of the function, the page returns as null.Thank you @tacov and @jfarthing84.
I’ve replace the code for the
in_array
variant however the code still removes all contact methods.The code now looks like this
function filter_user_contact_methods( $methods ) { $wanted_methods = array( 'city', 'state', 'zip' ); foreach ( $methods as $method => $label ) { if ( ! in_array( $method, $wanted_methods ) ) { unset( $methods[ $method ] ); } } return $methods; } add_filter( 'user_contactmethods', 'filter_user_contact_methods' );
Thank you @tacov.
I added the code to my function.php file however it removes all contact methods including the methods in the $wanted_methods array. How would I fix that?
Forum: Plugins
In reply to: [Theme My Login] Profile page edit and save contact info.@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 } ?>