Support

Account

Home Forums General Issues Display Name and role using a user field Reply To: Display Name and role using a user field

  • Wow, that was quick. A few minutes after having sent that post I noticed an error and corrected it.
    Please confirm that you have applied exactly what my previous post shows now.
    If you have done so and it did not work, please try this next and show me the dumped values from at least one iteration of that foreach. We are indeed getting closer:

    <h3>Asistentes</h3>
    <div>
    <?php $users = get_field('asistentes'); ?>
    <ul>
    <?php
    foreach ($users as $user):
    $roles = new WP_User( $user['ID'] ) ?? false ;
    var_dump( $user , $roles );
    $roles = is_object( $roles ) ? $roles->roles : [] ;
    var_dump( $roles );
    ?>
    <li>
    	<p><?php echo $user['display_name'];
    	echo 'User roles: ' . implode(', ', $roles) . "\n";?></p>
    </li>
    <?php endforeach; ?>
    </div>