Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am adding custom data to custom table while author posting a comment. Please find my code in my own answer here

add_action('comment_post', 'insert_gallery');
function insert_gallery() {

    global $wpdb, $post;
    $post_id = $post->ID;

        $wpdb->prefix. 'my_medias',
            'post_id' => $post_id,
            'image_name' => 'trial-image1',
            'status' => 1

Now I want to add one more column of 'author_ID' and not able to get the comment author id on the fly.

Can anyone help me to get comment author id on the fly and insert into custom table column author_ID

share|improve this question

1 Answer 1

Ah! It was so simple :P

Just using WP built in function

get_current_user_id( )

and all done. Thanks a lot.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.