3

I am trying to add an extra field or two underneath the "Name" or "About" section in the Wordpress user profile. So far I have only been able to accomplish this by:

//Begin
add_action('profile_personal_options',function(){
    ob_start();
});

//Grab Contents and Inject
add_action('show_user_profile',function($user){
        $contents = ob_get_contents();
    ob_end_clean();

    echo str_replace('<label for="description','!!!!!<label for="description',$contents);
});

But this seems like a dirty hack - what is the right way to accomplish this?

3
  • 1
    read: wpengineer.com/2173/custom-fields-wordpress-user-profile And adjust the author-bio template to call in your custom user meta.
    – shanebp
    Nov 6, 2014 at 20:34
  • I believe that just adds it to the bottom of the page, I was hoping to add it either to the name or about category
    – Corey
    Nov 6, 2014 at 20:46
  • Use this filter return apply_filters( 'get_the_author_' . $field, $value, $user_id );
    – shanebp
    Nov 6, 2014 at 21:59

1 Answer 1

0

check out my older article

HOW TO ADD WORDPRESS AUTHOR BIO & PROFILE PAGE

https://phirebase.com/blog/how-to-add-author-bio-profile-page/

just short example to add Twitter and Facebook fields:

function my_new_contactmethods( $contactmethods ) {
// Add Twitter
$contactmethods['twitter'] = 'Twitter';
//Add Facebook
$contactmethods['facebook'] = 'Facebook';
return $contactmethods;
}
add_filter('user_contactmethods','my_new_contactmethods',10,1);

Single loop

<?php the_author_meta('facebook'); ?>

– show facebook name

<?php the_author_meta('twitter'); ?>

– show twitter name

Author page

<?php echo $curauth->facebook; ?>

– show facebook name

<?php echo $curauth->twitter; ?>

– show twitter name

1
  • This doesn't answer the question. The OP specifically asks if there's a way to add a field under the Name or About section. This will add fields to the Contact Info section. Mar 3, 2017 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.