Member Directory

Permalink
Hello!

I was hoping this was a quick fix, but for the life of me, I can't find it. I'm trying to get it where the member directory displays the users' email. I'm already displaying all custom user attributes, but I'm not seeing anyway to control the email. Thanks!

rainmaker
 
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
To get the email, you need to get the user info object (not just the user object).
$userID = 1; // Your user ID
$ui = UserInfo::getByID($userID)
$email = $ui->getUserEmail();


http://www.concrete5.org/documentation/developers/permissions/users...
rainmaker replied on at Permalink Reply
rainmaker
Hey NetJunky!

I'm actually using the C5 single page for Member Directory so it's using a foreach loop to loop through the Public Profile attribute list. Here's the code:

foreach($users as $user) { 
         if($user->getUserID() != 1){
         ?>            
         <div class="ccm-profile-member">
            <!--<div class="ccm-profile-member-avatar"><?php echo $av->outputUserAvatar($user)?></div>-->
            <div class="ccm-profile-member-detail">
               <!-- 
               Only user if you want profiles enabled. (Make sure to enable public profiles in C5)
               <div class="ccm-profile-member-username"><a href="<?php echo $this->url('/profile','view', $user->getUserID())?>"><span class='attribute'>Username:</span> <?php echo $user->getUserName()?></a></div>
               -->
               <div class="ccm-profile-member-fields">
               <?php 
               $attribs = UserAttributeKey::getPublicProfileList();
               foreach($attribs as $ak) { ?>
                  <div class="member_row">


I was thinking there was a way to do it through the dashboard. No?
ScottSandbakken replied on at Permalink Best Answer Reply
ScottSandbakken
The email isn't a user attribute. It is part of the user info object, so you will need to grab it before your attribute loop.

/* **** Start User email *** */
$ui = UserInfo::getByID($user->getUserID());
$email = $ui->getUserEmail();
      echo "<span class='attribute'>Email</span> "; 
      echo "<span class='attribute_answer'>" . $email . "</span>";
/* **** End User email *** */


Here is the entire code block:
<?php
foreach($users as $user) { 
         if($user->getUserID() != 1){
         ?>
<div class="ccm-profile-member"> 
   <!--<div class="ccm-profile-member-avatar"><?php echo $av->outputUserAvatar($user)?></div>-->
   <div class="ccm-profile-member-detail"> 
      <!-- 
               Only user if you want profiles enabled. (Make sure to enable public profiles in C5)
               <div class="ccm-profile-member-username"><a href="<?php echo $this->url('/profile','view', $user->getUserID())?>"><span class='attribute'>Username:</span> <?php echo $user->getUserName()?></a></div>
               -->
      <div class="ccm-profile-member-fields">
         <?php 
         /* **** Start User email *** */
            $ui = UserInfo::getByID($user->getUserID());
rainmaker replied on at Permalink Reply
rainmaker
Ah gotcha. :) Worked like a charm! Thank you much!