How to add custom fields to users

Sometimes we need to keep extra information about our users and we can do this by adding new custom fields.

Sometimes we need to keep extra information about our users and we can do this by adding new custom fields.

Place this in functions.php
NOTE: if you are using a child theme, place it in child theme’s functions.php

function wcr_user_fields($user) {
    ?>
    


ID); foreach ($types_array as $type) { ?> />
'name', 'order' => 'ASC' )); $checked_value = get_the_author_meta('categories', $user->ID); foreach ($categories_array as $category) { ?> term_id, $checked_value) ? 'checked="checked"' : ''; ?>/>

When you need to show the info just use the get_the_author_meta function:

// get age of the user with ID = 1
echo get_the_author_meta('age', 1);

You can also read about How to add custom fields to categories :)

Leave a Reply

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