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?

1 Answer
1

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

Leave a Reply

Your email address will not be published. Required fields are marked *