Support

Account

Home Forums Backend Issues (wp-admin) User relationship field population Reply To: User relationship field population

  • Currently using this code, which displays nothing.

    The user is returning User Objects. So not sure if this is just missing something to make it work right.

    <div class="connectedtoyou usersloop teamloop" style="margin-top:40px!important;margin-bottom:40px!important;display:none!important;">
    <hr>
    <div class="users">
    <h3 class="center centered">Users connected to you</h3>
    <?php
    $current_user = wp_get_current_user();
    $connect_user = 'user_'.$current_user->ID;
    $connect_field = get_field('user_follows');
    
    $args = array(
        'meta_key'     => $connect_field,
        'meta_value'   => $connect_user,
    );
    
    $user_query = new WP_User_Query( $args );
    
    if ( ! empty( $user_query ) ) { ?>
    <div class="row isotope">
        <?php foreach( $user_query as $user ): ?>
    	<div class="col fade-up item">
    			<div class="item-container"><a href="<?php echo get_author_posts_url( $user->id ); ?>" style="text-decoration:none!important;">
    				<?php if ('health' == get_user_meta($user->ID, 'mepr_select_ident', true)) { ?><img src="<?php echo get_home_url(); ?>/wp-content/uploads/2023/01/D4HGN_Logo_2.png" alt="Health">
    				<?php } elseif ('design' == get_user_meta($user->ID, 'mepr_select_ident', true)) { ?><img src="<?php echo get_home_url(); ?>/wp-content/uploads/2023/01/D4HGN_Logo_1.png" alt="Design">
    				<?php } elseif ('research' == get_user_meta($user->ID, 'mepr_select_ident', true)) { ?><img src="<?php echo get_home_url(); ?>/wp-content/uploads/2023/01/D4HGN_Logo_3.png" alt="Research">
    				<?php } elseif ('global' == get_user_meta($user->ID, 'mepr_select_ident', true)) { ?><img src="<?php echo get_home_url(); ?>/wp-content/uploads/2023/01/D4HGN_Logo_4.png" alt="Global">
    				<?php } elseif ('network' == get_user_meta($user->ID, 'mepr_select_ident', true)) { ?><img src="<?php echo get_home_url(); ?>/wp-content/uploads/2023/01/D4HGN_Logo_5.png" alt="Network">
    				<?php } else { ?>
    				<?php } ?>
    				<h4 class="darkgrey"><?php echo esc_html( $user->first_name ); ?> <?php echo esc_html( $user->last_name ); ?></h4>
    			</a></div>
    			</div>
        <?php endforeach; ?>
    </div>
    <?php } else { ?>
    <p>No users are connected to you. <a href="https://d4hgn.com/network/network-users/">Click here to see who's on the network</a>.</p>
    <?php }  wp_reset_postdata(); ?>
    </div>
    </div>