get_current_user_id()
14th January 2021
0 Comments
Framework / CMS
WordPress [Version: Since 3.0.0]
Syntax
Typical Usage
Get the current logged in user’s ID in WordPress.
Accepted Parameters
None
Return Value(s)
Returns the current user’s ID as an integer, or 0 if no user is logged in.Examples of get_current_user_id()
Example 1
<?php
$user_id = get_current_user_id();
The above will return the logged in user’s ID as an integer, or 0 if the user is not logged in.
Used In Projects
Was This Helpful?
If this post has helped you, please let me know. Your feedback will be highly appreciated and will help me build better content.