Skip to:
Content
Pages
Categories
Search
Top
Bottom

getting logged in user info

Viewing 3 replies - 1 through 3 (of 3 total)

  • Barry
    Participant

    @barryhughes-1


    abhipatodi
    Participant

    @abhipatodi

    To check if the user is logged in, is_user_logged_in() is used:
    function is_user_logged_in() {
    $user = wp_get_current_user();
    return $user->exists();
    }
    True if user is logged in, false if not logged in.

    To obtain the default data (such as User ID, User Login, etc.)of the user try this code:

    global $bp;
    $the_user_id = $bp->loggedin_user->userdata->ID;
    $the_user_login = $bp->loggedin_user->userdata->user_login;

    To get data for the current logged in user, this this:
    `$the_first_name = bp_get_profile_field_data(‘field=First Name&user_id=’.bp_loggedin_user_id());

    Hope you find these code lines useful.


    Barry
    Participant

    @barryhughes-1

    Just to note, is_user_logged_in() ships as part of WordPress itself, there’s generally no need to redefine it from your own code (unless you are perhaps reimplementing the login system).

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar