Support

Account

Home Forums Front-end Issues Show Custom Fields in a User Profile on Frontend

Solving

Show Custom Fields in a User Profile on Frontend

  • Hi there,

    We are building a website for a client. This client requires certain information to be input on user accounts on their website.

    We have put together the fields for this in the User Profile, but the client would also like this to display on the front end.

    E.g.

    Customer signs up and purchases – their purchases are then manually input in to the fields on their User Profile. When this customer logs in, our client would like to be able to display this information (or these fields/table) in the My Account page.

    We are using Elementor Pro and I’ve tried pretty much everything to get this to work, but no luck.

    Any help with this is greatly appreciated as this is a good feature and we’d like to replicate this across other sites!

    Many thanks in advance.

  • HI @reason8

    You can access the data from a user using:

    
    <?php
    if ( is_user_logged_in() ) :
    
    	$user_id = get_current_user_id();
    	$value = get_field( 'my_field', "user_".$user_id );
    	if($value):
    		echo $value;
    	endif;
    
    endif;
    

    You’d just need to add that in to your template

  • Thanks @jarvis. So do I add this to my functions.php file?

    I’ll tell you what I need as I’m back on this now.

    I am working for a client who needs to be able to add custom data to each user on their site.

    They then want this data to show on the frontend when the user is logged in.

    I’ve created a repeater with subfields for the data entry.

    I am using Elementor so do I need a shortcode?

    How do I get this data to show on a specific page when the user is logged in?

    Many thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.