Friday 12 December 2014

wordpress logged in user related things

global $current_user  - > this shows current logged in user.

print_r($current_user);  - will give all details of current user
$cid =  $current_user->ID;  -- fetch id of current user.
echo $cid;   gives value
$custom_fields = get_post_custom($cid);  pass this id to this function and get the values of custom fields
related with current user.

print_r($custom_fields);  will display all details of custom fields
  die;

GET_USER_META - gives all the values associated with logged in user
$user_last = get_user_meta( $cid );

No comments:

Post a Comment