Get User ID from within a plugin

If you want current user id only then use get_current_user_id.
because it reduce execution time. get_current_user_id get only current user id where wp_get_current_user get all user data.
Else every things is perfect.

$user_id = get_current_user_id();

$loc_statuss = $wpdb->get_row( "SELECT status FROM profile_location INNER JOIN relation_user ON profile_location.loc_id=relation_user.loc_id WHERE relation_user.user_id=".$user_id );
$loc_status = $loc_statuss->status;

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)