0

I am adding custom data to custom table while author posting a comment. Please find my code in my own answer here https://wordpress.stackexchange.com/a/85109/9821

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

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

    $wpdb->insert(
        $wpdb->prefix. 'my_medias',
        array(
            'post_id' => $post_id,
            'image_name' => 'trial-image1',
            'status' => 1
        ),            
        array(
            '%d',
            '%s',
            '%d'
        )            
    );            
}

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

1 Answer 1

1

Ah! It was so simple :P

Just using WP built in function

get_current_user_id( )

and all done. Thanks a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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