• Resolved PennyHaynes

    (@pennyhaynes)


    I have a custom module I’ve created and need to insert data into wp_comments. The insert works, but SOME variables are ending up as empty values in the db.

    In my $data array, I am trying to pass variables such as $comment_post_ID, comment_author, etc., but they end up empty in the database. However, I can pass $comment_author_IP no problem.

    I know the variables that are disappearing will print in an echo statement right before going into the $data array, so I thought it might be a syntax problem in the array. But I saw documentation where you could pass variables as values.

    Anyway, here is the code. What am I doing wrong???

    `$data = array(
    ‘comment_post_ID’ => $comment_post_ID,
    ‘comment_author’ => $comment_author,
    ‘comment_author_email’ => $comment_author_email,
    ‘comment_author_url’ => $comment_author_url,
    ‘comment_content’ => $comment_content,
    ‘comment_type’ => ”,
    ‘comment_parent’ => 0,
    ‘user_id’ => 0,
    ‘comment_author_IP’ => $comment_author_IP,
    ‘comment_agent’ => $comment_agent,
    ‘comment_date’ => $time,
    ‘comment_approved’ => 0
    );`

    Thanks for the help.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘wp_new_comment will not insert my variables’ is closed to new replies.