• Resolved Chris

    (@lamordnt)


    I have created a custom printable members list template and I am trying to display the email address for each member on there but it isn’t working. I created an html table and have it setup like so:

    				<tr>
    					<td><code>user.display_name_html</code></td>
    					<td><code>user.phone_number</code></td>
    					<td><code>user.mobile_number</code></td>
    					<td><code>user.user_email</code></td>
    					<td><code>user.community_address</code></td>
    				</tr>
    

    All my fields work except for “user.user_email”.

    What is the correct way to display the users email address in a members list template?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @lamordnt

    >>> What is the correct way to display the users email address in a members list template?

    Did you create a custom Member list template for UM Member Directory? Are you able to provide the full code so I can review?

    Regards,

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @lamordnt

    …Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

    Thread Starter Chris

    (@lamordnt)

    Sorry we had some power outages that took me offline for awhile. I still have not been able to figure this out. Here is the full code of my template that I am using:

    <script type=”text/template” id=”tmpl-um-member-list-<?php echo esc_attr( $unique_hash ) ?>”>
    <table class=”um-members-list”>
    <thead>
    <tr>
    <th>Name</th>
    <th>Home Phone</th>
    <th>Mobile Phone</th>
    <th>Email</th>
    <th>Address</th>
    </tr>
    </thead>
    <tbody>
    <# if ( data.length > 0 ) { #>
    <# _.each( data, function( user, key, list ) { #>

    <tr>
    <td>user.display_name_html</td>
    <td>user.phone_number</td>
    <td>user.mobile_number</td>
    <td>user.user_email</td>
    <td>user.community_address</td>
    </tr>

    <# }); #>
    <# } else { #>

    <div class=”um-members-none”>
    <p><?php echo $no_users; ?></p>
    </div>

    <# } #>
    </tobdy>
    </table>
    </script>`
    `

    I am trying to get the user email field to show up. This would be pulling from the email address tied to the account. It isn’t working for me. Any idea?

    Thread Starter Chris

    (@lamordnt)

    For some reason it is stripping out my code. Here is the code on pastebin: https://pastebin.com/r0mwnRGy

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @lamordnt

    Try adding the user_email with the code snippet so that you can bind it with your custom template:

    add_filter("um_ajax_get_members_data","um_0303212_profile_avatar_members_data", 10, 3 );
    function um_0303212_profile_avatar_members_data( $data_array, $user_id, $directory_data ){
    
        $data_array['user_email'] = um_user("user_email");
        
       
        return $data_array;
    
    }

    Regards,

    Thread Starter Chris

    (@lamordnt)

    Wow this helped alot, thank you! I actually realized I already had an array doing the same thing in my functions.php file (which for anyone else is where this code goes). Below is what I ended up with in case it helps anyone else:

    function my_um_ajax_get_members_data( $data_array, $user_id, $directory_data ) {
          $arr_fields = array(
             'phone_number',
             'mobile_number',
             'community_address',
             'user_email',
          );
          foreach( $arr_fields as $field_key ){
               $field_value = um_user( $field_key ); 
               if( $field_value ){ 
    		  $data_array[ $field_key ] = $field_value;
                    }else{
                     $data_array[ $field_key ] = '';
               }
          } 
          return $data_array;
    }
    add_filter( 'um_ajax_get_members_data', 'my_um_ajax_get_members_data', 10, 3 );

    I just added ‘user_email’ to the array and then when I input the following on my template file it works:

    <code>user.user_email</code>

    (where it says code it should be three curly brackets but the forum strips it out.)

    • This reply was modified 3 years, 9 months ago by Chris. Reason: formatting
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Display each members email address on custom members list template’ is closed to new replies.