Usage
PHP
nebula()->get_user_info($datapoint, $options)
Parameters
$datapoint
(Optional) (String) The user meta name to retrieve
Default: None
$options
(Optional) (Array)
Default: None
Parameter Notes
$options
include:
- ‘id’ (default:
get_current_user_id()
) - ‘prepend’
- ‘append’
Examples
Append the user's email address in a query string if available
PHP
echo 'https://gearside.com/' . nebula()->get_user_info('user_email', array('prepend' => '&nv-email='))
Additional Notes
If a specific datapoint is not passed, the entire userdata object is returned. If the datapoint is not available it returns false.
Source File
Located in /libs/Functions.php on line 2305.
No Hooks
This function does not have any filters or actions available. Request one?
PHP
public function get_user_info($datapoint, $options=array()){ $defaults = array( 'id' => get_current_user_id(), 'datapoint' => $datapoint, 'fresh' => false, 'prepend' => '', 'append' => '', 'fallback' => false, ); $data = array_merge($defaults, $options); if ( empty($data['id']) ){ //If there is no user or current user is not logged in return $data['fallback']; } //Get from object cache unless specifically requested fresh data if ( !$data['fresh'] ){ $userdata = wp_cache_get('nebula_user_info', 'user-id-' . $data['id']); } if ( empty($userdata) ){ $userdata = get_userdata($data['id']); wp_cache_set('nebula_user_info', $userdata, 'user-id-' . $data['id']); //Store in object cache } if ( !empty($data['datapoint']) ){ $requested_data = $data['datapoint']; if ( !empty($userdata->$requested_data) ){ return $data['prepend'] . $userdata->$requested_data . $data['append']; } else { return $data['fallback']; } } if ( !empty($userdata) ){ return $userdata; } return $data['fallback']; }
Override
This function can not be short-circuited with an override filter. Request one?