A
A
Alex_872021-12-07 18:56:46
WordPress
Alex_87, 2021-12-07 18:56:46

How to properly add feedback fields to the WP admin using wp_insert_comment?

There wp_insert_comment()is an array in the documentation

$data = [
 'comment_post_ID'      => 1,
 'comment_author'       => 'admin',
 'comment_author_email' => '[email protected]',
 'comment_author_url'   => 'http://',
 'comment_content'      => 'content here',
 'comment_type'         => 'comment',
 'comment_parent'       => 0,
 'user_id'              => 1,
 'comment_author_IP'    => '127.0.0.1',
 'comment_agent'        => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)',
 'comment_date'         => null, // получим current_time('mysql')
 'comment_approved'     => 1,
];

Considering what fields I need (that is, this data will be entered by the user for feedback)
- Name
- avatar
- City
- Post title (this field is very important - the review will be added to the custom entity record by this name)
- Comments (by design, it can have both a short and expanded view)

Where should they be written down correctly?

For example: 'comment_content' =>suitable for a comment, and so on...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2021-12-07
@artzolin

You can add the values ​​you want with the comment_meta argument

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question