Wordpress SEO - What are you looking for?

If you're looking for answers to SEO or wordpress related questions, type in a phrase and wait for hints or click enter! The results also show links to external sources.

161 articles in the database

Adding and displaying fields in a WP user profile

[ Article content is protected by Plagiashield ]

Working with WordPress we often want registrants users were able to complete their profile We ask for the data we are interested in, e.g. address profile Facebook or age. Today will show like plain can be add fields in panel user.

In the SQL database WordPress stores in a table called wp_usermeta data corresponding to specific users. They are displayed in the administration panel in Users => Your Profile. The table is built in such a way that you can easily extend it with new records. The code below is responsible for adding three fields corresponding to links to the most popular social profiles. To functions.php file in our template we add:

add_action( 'show_user_profile', 'add_extra_social_links' );
add_action( 'edit_user_profile', 'add_extra_social_links' );

function add_extra_social_links( $user )
{
    ?>
        

Social profiles

.

This is more or less how it should display:

profile-profile

Recording of data

The rule responsible for saving the data in the database is also necessary. It can be located directly after the code displayed above.

add_action( 'personal_options_update', 'save_extra_social_links' );
add_action( 'edit_user_profile_update', 'save_extra_social_links' );

function save_extra_social_links( $user_id )
{
    update_user_meta( $user_id,'facebook_profile', sanitize_text_field( $_POST['facebook_profile'] ) );
    update_user_meta( $user_id,'twitter_profile', sanitize_text_field( $_POST['twitter_profile'] ) );
    update_user_meta( $user_id,'google_profile', sanitize_text_field( $_POST['google_profile'] ) );
}

How to display data?

As an example, I gave a field responsible for displaying a link to a Twitter profile.

the_author_meta( 'twitter_profile', $userID );

Plugins

Of course, for more complex projects I recommend using plugs. I personally use two solutions namely: User Meta and Profile Builder PRO. Below is a screen shot of dashboard the first one. As you can see, there is a power 🙂 .

Source: https://wordpress.org/plugins/user-meta/screenshots/

Wojciech Wladzinski

O Wojciech Wladzinski

I have been dealing with SEO industry since 2008. At co day senior SEO specialist in the company Seogroup. I create and optimize large websites as well as smaller ones websites online. I am particularly fond of the environment WordPresswhich, despite popular belief, is not just a blogging platform.
  • Internal Links and Sematics

  • Link building
  • Sematics
  • Link building has never been easier. Hundreds of link possibilities in one click.
  • See

[ Article content is protected by Plagiashield ]

SEMRush - the best tool for SEO and PPC.

en_USEnglish
Read previous post:
wordpress-fix
7 common WordPress problems and solutions

From this article you will learn what to do when screen options don't work, when wordpress doesn't save changes, and when during...

Close