jetpack_current_user_data

Gather data about the current user.

Description

(array) jetpack_current_user_data(); 

Returns (array)


Usage

  1. if ( !function_exists( 'jetpack_current_user_data' ) ) { 
  2. require_once '/_inc/lib/admin-pages/class.jetpack-react-page.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = jetpack_current_user_data(); 
  7.  

Defined (1)

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

/_inc/lib/admin-pages/class.jetpack-react-page.php  
  1. function jetpack_current_user_data() { 
  2. $current_user = wp_get_current_user(); 
  3. $is_master_user = $current_user->ID == Jetpack_Options::get_option( 'master_user' ); 
  4. $dotcom_data = Jetpack::get_connected_user_data(); 
  5. // Add connected user gravatar to the returned dotcom_data. 
  6. $dotcom_data['avatar'] = get_avatar_url( $dotcom_data['email'], array( 'size' => 64, 'default' => 'mysteryman' ) ); 
  7.  
  8. $current_user_data = array( 
  9. 'isConnected' => Jetpack::is_user_connected( $current_user->ID ),  
  10. 'isMaster' => $is_master_user,  
  11. 'username' => $current_user->user_login,  
  12. 'wpcomUser' => $dotcom_data,  
  13. 'gravatar' => get_avatar( $current_user->ID, 40, 'mm', '', array( 'force_display' => true ) ),  
  14. 'permissions' => array( 
  15. 'admin_page' => current_user_can( 'jetpack_admin_page' ),  
  16. 'connect' => current_user_can( 'jetpack_connect' ),  
  17. 'disconnect' => current_user_can( 'jetpack_disconnect' ),  
  18. 'manage_modules' => current_user_can( 'jetpack_manage_modules' ),  
  19. 'network_admin' => current_user_can( 'jetpack_network_admin_page' ),  
  20. 'network_sites_page' => current_user_can( 'jetpack_network_sites_page' ),  
  21. 'edit_posts' => current_user_can( 'edit_posts' ),  
  22. 'publish_posts' => current_user_can( 'publish_posts' ),  
  23. 'manage_options' => current_user_can( 'manage_options' ),  
  24. 'view_stats' => current_user_can( 'view_stats' ),  
  25. 'manage_plugins' => current_user_can( 'install_plugins' ) 
  26. && current_user_can( 'activate_plugins' ) 
  27. && current_user_can( 'update_plugins' ) 
  28. && current_user_can( 'delete_plugins' ),  
  29. ),  
  30. ); 
  31.  
  32. return $current_user_data;