I’m trying to echo an ACF value on the frontend woocommerce My Account page. The value is stored against a user account. The only problem i’m having is getting the value from the current logged in user.
I’ve got the following code which should work according to http://www.advancedcustomfields.com/resources/how-to-get-values-from-a-user/ should work.
<?php $user_ID = get_current_user_id();
$number = "user_$user_ID";
the_field('domain_name', $number); ?>
But it doesn’t! As soon as i remove the
$number = "user_$user_ID";
and replace it with
$number = "user_3";
it works perfectly….but this is a hardcoded value, rather than calling the current user ID
Any help would be appreciated.
You should be forming the $number like this:
This is working for me:
You should use it like this: