bb_user_row

The BuddyPress bb user row function.

Description

bb_user_row( $user, (string) $role = '', (bool) $email = false ); 

Parameters (3)

0. $user
The user.
1. $role — Optional. (string) => ''
The role.
2. $email — Optional. (bool) => false
The email.

Usage

  1. if ( !function_exists( 'bb_user_row' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php'; 
  3.  
  4. // The user. 
  5. $user = null; 
  6.  
  7. // The role. 
  8. $role = ''; 
  9.  
  10. // The email. 
  11. $email = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bb_user_row($user, $role, $email); 
  15.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-admin/includes/functions.bb-admin.php  
  1. function bb_user_row( $user, $role = '', $email = false ) { 
  2. $actions = "<a href='" . esc_attr( get_user_profile_link( $user->ID ) ) . "'>" . __('View') . "</a>"; 
  3. $title = ''; 
  4. if ( bb_current_user_can( 'edit_user', $user_id ) ) { 
  5. $actions .= " | <a href='" . esc_attr( bb_get_user_admin_link( $user->ID ) ) . "'>" . __('Edit') . "</a>"; 
  6. $title = " title='" . esc_attr( sprintf( __( 'User ID: %d' ), $user->ID ) ) . "'"; 
  7. $r = "\t<tr id='user-$user->ID'" . get_alt_class("user-$role") . ">\n"; 
  8. $r .= "\t\t<td class=\"user\">" . bb_get_avatar( $user->ID, 32 ) . "<span class=\"row-title\"><a href='" . get_user_profile_link( $user->ID ) . "'" . $title . ">" . get_user_name( $user->ID ) . "</a></span><div><span class=\"row-actions\">$actions</span> </div></td>\n"; 
  9. $r .= "\t\t<td><a href='" . get_user_profile_link( $user->ID ) . "'>" . get_user_display_name( $user->ID ) . "</a></td>\n"; 
  10. if ( $email ) { 
  11. $email = bb_get_user_email( $user->ID ); 
  12. $r .= "\t\t<td><a href='mailto:$email'>$email</a></td>\n"; 
  13.  
  14. $registered_time = bb_gmtstrtotime( $user->user_registered ); 
  15. if ( $registered_time < ( time() - 86400 ) ) { 
  16. $time = date( 'Y/m/d\<\b\r \/\>H:i:s', bb_offset_time( $registered_time ) ); 
  17. } else { 
  18. $time = sprintf( __( '%s ago' ), bb_since( $registered_time ) ); 
  19.  
  20. $r .= "\t\t<td>" . $time . "</td>\n"; 
  21.  
  22. if ( 
  23. !isset($user->capabilities) || 
  24. !is_array($user->capabilities) || 
  25. empty($user->capabilities) 
  26. ) { 
  27. $role = array( __('Inactive (no role)') ); 
  28. } else { 
  29. global $wp_roles; 
  30. $_roles = $wp_roles->get_names(); 
  31. $role = array(); 
  32. foreach ( $user->capabilities as $cap => $cap_set ) { 
  33. if (!$cap_set) { 
  34. continue; 
  35. $role[] = $_roles[$cap]; 
  36. if ( !count( $role ) ) { 
  37. $role[] = __('None'); 
  38.  
  39. $r .= "\t\t<td>" . join(', ', $role) . "</td>\n\t</tr>"; 
  40. return $r;