Home › Forums › General Issues › Featured Profiles Section
I am trying to pull the users image, first name & last name.
Example:
I have a florida post page and at the top of the page.
I want to feed in, profiles that are attached to the “florida” role.
The user image, first & last name, I need to pull from the users values.
Basicly, when people visit the florida post page, they will see these featured profiles at the top.
This is what I have so far, currently cant figure out how to get it to pull from the user meta.
$link = get_author_posts_url( $value['ID'] ); //get the url
$image = get_field("featured_image");
$name = get_field("featured_name");
?>
<div class="featured-profiles">
<div class="profile-image">
<img src="<?php echo $image; ?>"/>
</div>
<div class="profile-name">
<h4><?php echo $name; ?></h4>
</div>
</div>
I have also attahed an image for reference of what im looking to complete.
Update:
So far I have been able to find a way to pull in the name and gravatar image. However instead of the gravatar I want to be able to pull the image the user set on a subfield within a repeater. My users have a front-end form they setup for their profile, and there user image is what I want to pull in.
Currently working, not ideal:
$profilepic = get_sub_field('picture' );
$users = get_field("florida");
?>
<div class="avatar">
<span>
<?php
$user = wp_get_current_user();
if ( $user ) :
?>
<img src="<?php echo esc_url( get_avatar_url( $user->ID ) ); ?>" />
<?php endif; ?>
</span>
</div>
<div class="avatar-details">
<span>
<?php if( $users ): ?>
<?php foreach( $users as $user ): ?>
<a href="<?php echo esc_attr($user->user_url); ?>"><?php echo $user->display_name; ?></a>
</span>
<?php endforeach; ?>
</div>
<?php endif; ?>
Almost working? :
$users = get_field("florida");
?>
<div class="avatar">
<?php if( have_rows('contact_details', 'user_'. $author_id )): ?>
<div>
<?php while ( have_rows('contact_details', 'user_'. $author_id )): the_row();
$author_id = get_the_author_meta('ID');
$profilepic = get_sub_field('picture', 'user_'. $author_id ); ?>
<span>
<img src="<?php echo $profilepic; ?>" />
</span>
<?php endwhile; ?>
<?php endif; ?>
</div>
<div class="avatar-details">
<span>
<?php if( $users ): ?>
<?php foreach( $users as $user ): ?>
<a href="<?php echo esc_attr($user->user_url); ?>"><?php echo $user->display_name; ?></a>
</span>
<?php endforeach; ?>
</div>
<?php endif; ?>
So i think the issue is it doesen’t see the rows, so anything after <?php if( have_rows('contact_details', 'user_'. $author_id )): ?>
seems to get removed and doesent show within inspect?
You must be logged in to reply to this topic.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.