Support

Account

Home Forums Front-end Issues Display pictures in the right place

Solved

Display pictures in the right place

  • Hello. Trying to implement the user’s personal account, wherein by different profile fields can upload their cover. Loading works fine, but I can not bring in the right place at the very cover. It looks like this:

    Here is the code that I bring groups of fields:

    <?php 
    
     $options = array(
     'post_id' => 'user_'.$current_user->ID, // $user_profile,
     'field_groups' => array(739),
     'submit_value' => 'Update Profile'
     );
    
     echo 'Ваш логин<b> '.$current_user->user_login.'</b>. This cannot be changed.
    ';
    
     acf_form( $options ); 
     }
    
     ?>

    Print the image in the right place tried this code, but it does not display anything:

    <?php $field = get_field('cover_profile', false, false); ?>

    p.s. I am sorry for my bad english

  • ACF form will not display the image in the header of the page, it only shows the input. If you want to show the image in the header as well then you need to alter the template that shows that page and use the correct acf functions for getting and displaying the values https://www.advancedcustomfields.com/resources/image/

  • Thanks for the reply. I tried different options, including the link You specified. Only works the code that I presented above and it displays all the field group 739. I need to withdraw one field cover_profile, which is also located in the group of 739, but it does not want displayed)

    The last thing I tried:

    <?php if( get_field('cover_profile') ): ?>
    	<img src="<?php the_field('cover_profile'); ?>" />
    <?php endif; ?>

    Not working. In the place where there should be picture – empty.

  • acf_form() is only used to present the form.

    You need to get the image from the user field and show it in the location where you want it displayed. See getting values from other places https://www.advancedcustomfields.com/resources/get_field/

    
    $post_id = 'user_'.$current_user->ID;
    <?php if( get_field('cover_profile', $post_id) ): ?>
    	<img src="<?php the_field('cover_profile', $post_id); ?>" />
    <?php endif; ?>
    

    make sure you are returning the right type of value. The above code means that you have the image field set to return the URL or the image.

  • Oh, it works, thanks!

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

You must be logged in to reply to this topic.