Get current user id

Question

I need to print the user’s id into this array but it doesn’t seem to be working. I have tried all sorts of things from $user->ID to $user_id to no avail. I am trying to get the value from my functions.php
Any help would be greatly appreciated!

Here what’s in my php function:

$user_page = get_queried_object();
$user_id = $user_page->data->ID;
$args = array(
        'post_type' => 'listings',
        'post_status'    => 'publish',
        'meta_query' => array(
            array(
                'key' => 'stm_car_user',
                'value' => $user_id
            )
        )
    );

$query = new WP_Query($args);

I’m sorry if my question is a little vague, here is what I am trying to achieve I don’t want to get the id of the currently logged in user, I want to get the id of the user that the information is on, I am displaying the user’s posts on their profiles and I need their id’s displayed dynamically for each profile, you get me? I hope this clarifies things…

0
, , , Matt H 3 years 2020-08-26T15:10:25-05:00 0 Answers 63 views 0

Leave an answer

Browse
Browse