Home › Forums › General Issues › Grab relationship field from user profile › Reply To: Grab relationship field from user profile
After doing a var_dump on $company, the reason why echoing $compmany wasn’t pulling anythng was because it was a wp object or wp array (I’m not sure of the correct terminology.
I had to select the post_title in order for it to work. So I ended up with this:
function user_organization($atts) {
$user_id = get_current_user_id();
$user_company = get_field('user_company', 'user_' . $user_id);
echo $user_company->post_title;
}
add_shortcode('user_organization_info', 'user_organization');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.