Display custom user profile fields in wordpress

i’m using this answer as a playground for helping you out here. better, than in the comment section. for anybody else stumbling about the same question: i recommended ACF as a plugin for custom fields, as it is well maintained and can add custom fields to anything inside wordpress (posts, pages, attachments, taxonomies…)

to get the current user and their fields, it would go something like this

function so380508_get_user_total(){

    $user_id = get_current_user_id();

    // @todo - validate we have a user ID

    $user_total = get_field('total', 'user_' . $user_id);

    // @todo - validate field data returned - if an array, get required data in printable format

    // @todo - format markup and return

    echo '<pre>' . print_r($user_total, 1) . '</pre>';

}

and inside your template file you need to call so380508_get_user_total();

of course you need to create the field ‘total’ as a custom field for users. and for testing purposes create a user, fill that field with a random value, login as that user and see, if you get, what you are looking for.