无法将Wordpress帖子ID发送到Echo或插入数据库

I've got this code written that when a link is clicked is supposed to insert the current user's id, the current post's id, and the date into a database. The current user id & the current date get inserted into the database and echo's perfectly, but I can't get the current post's id to "echo" or get it to insert into the database. Here's the code I have so far:

global $post;
    global $wpdb;
    $wp_user_id = get_current_user_id(); 
    $activity_post_id = $wp_query->post->ID;
    $activity_added = current_time('mysql', 1);

    echo "<h2>The Current User ID is: ". $wp_user_id . "</h2>";
    echo "<h2>The Current Activity ID is: ". $activity_post_id . "</h2>";
    echo "<h2>The Current Date / Time is: ". $activity_added . "</h2>";

    $wpdb->insert(
        'wp_growwellactivities',
        array(
            'wp_user_id' => $wp_user_id,
            'activity_post_id' => $activity_post_id,
            'date_added' => $activity_added
        )
    ); 

You're attempting to access wp_query without using the global.

Change your globals to:

global $post, $wp_query, $wpdb;

Or use this instead:

$activity_post_id = $post->ID;