wp get logged in user id
<?php
$user_id = get_current_user_id();
?>
wp get logged in user id
<?php
$user_id = get_current_user_id();
?>
wp get user meta
<?php
$meta_data = get_user_meta($user_id, $key, $single);
?>
how to get user meta in wordpress
function get_usermeta( $user_id, $meta_key = '' ) {
_deprecated_function( __FUNCTION__, '3.0.0', 'get_user_meta()' );
global $wpdb;
$user_id = (int) $user_id;
if ( !$user_id )
return false;
if ( !empty($meta_key) ) {
$meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
$user = wp_cache_get($user_id, 'users');
// Check the cached user object.
if ( false !== $user && isset($user->$meta_key) )
$metas = array($user->$meta_key);
else
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) );
} else {
$metas = $wpdb->get_col( $wpdb->prepare("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user_id) );
}
if ( empty($metas) ) {
if ( empty($meta_key) )
return array();
else
return '';
}
$metas = array_map('maybe_unserialize', $metas);
if ( count($metas) == 1 )
return $metas[0];
else
return $metas;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us