WordPress.org

Ready to get started?Download WordPress

Forums

Private Content
[resolved] How do I find the User ID of the logged in User (2 posts)

  1. TotalBeginner
    Member
    Posted 1 year ago #

    Hi.
    Your Plugin works great, but now I have to write the PHP code for the Private Page and I need the ID of the User that is logged into this plugin.

    For example the user who is logged in right now has the User_ID 2. Can i read that value somewhere in the database or is there any other way?

    Cheers

    http://wordpress.org/extend/plugins/private-content/

  2. aldolat
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,
    you can get the current user's ID using:

    <?php $my_user = get_current_user_id(); ?>

    Now $my_user contains the userID.

    Another way is to use the $current_user global variable in this way:

    <?php global $current_user;
    $my_user = $current_user->ID; ?>

    Bye.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.