ACF dynamic image field for user is not working on webpage

[ad_1]

I am using ACF to show different dynamic values in the user dashboard. All the other fields are working fine. But when I want to show a dynamic image then it creates problem. I am useing elementor pro. So I thing it is a problem with elementor pro and ACF. So I go for custom code. At first I add a custom image field for a post, and use this code.

<?
php $image = get_field($post_image);
$pic = $image[‘sizes’][‘large’];
?>

<p><?php echo $pic; ?>
</p> <?php var_dump($image);?>

and this code is working fine. But when I try to show image of a user with a code. it just shows me image id, not image. all image ACF settings are same for both post and user image field.

there is two code: one is:

<?php $user_id = get_current_user_id();
$user = get_user_by( ‘id’, $user_id);
$userimg = get_field(“$realtor_image”,$user);

if( $userimg ) {
echo $userimg; }
else {
echo ’empty’; }
?>

another is:

<?php $user_id = get_current_user_id();
$user = get_user_by( ‘id’, $user_id);
$userimg = $user->realtor_image; ?>

<p><?php echo $user->realtor_image; ?>
</p> <?php var_dump($userimg);?>

and in the screenshot, you will see those above the line and below the like. Can anyone please help me?
Output ss: [https://imgur.com/a/dPWqOoK])
Here is my image field ss: [https://imgur.com/a/MQxca3m])

I am trying to show the image that is different from user to user, like what ACF actually does, showing dynamic content. I can do it for posts, but not for logged-in users. It is showing me the image id rather than the actual image. I have changed Return Format, but not work.

[ad_2]
1 Comment
  1. Second parameter of get_field is a string, not a user object.

    Try :

    $userimg = get_field(“$realtor_image”,”user_”.get_current_user_id());

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer