From "textarea field" to "Comments"

This topic contains 4 reply and 2 voices, and was last updated by Tareq Hasan 11 years ago
Viewing 4 Posts - 1 through 4 (of 4 total)
Author Posts
April 21, 2013 at 8:59 am 2633
Tareq Hasan Hello, ¿It's possible to pass info from the "textarea form field" to a "Comment" for that post? Thank you.
April 21, 2013 at 11:56 am 2643
Tareq Hasan Tareq Hasan

It might be possible, but I am not sure about your context. What you are trying do?

April 21, 2013 at 2:13 pm 2644
Tareq Hasan Tareq Hasan

That can be done using action hook provided by the plugin.

[php]
function wpufe_insert_first_comment( $post_id ) {
if ( isset( $_POST[‘comment’]) ) {
$message = $_POST[‘comment’];

if ( !empty( $message ) ) {
$user = wp_get_current_user();
$commentdata = array(
‘comment_author_IP’ => preg_replace( ‘/[^0-9a-fA-F:., ]/’, ”, $_SERVER[‘REMOTE_ADDR’] ),
‘comment_agent’ => substr( $_SERVER[‘HTTP_USER_AGENT’], 0, 254 ),
‘comment_content’ => $message,
‘comment_post_ID’ => $post_id,
‘user_id’ => $user->ID,
‘comment_author’ => $user->display_name,
‘comment_author_email’ => $user->user_email,
);

$comment_id = wp_insert_comment( $commentdata );

if ( class_exists( ‘CommentRatingFieldPlugin’ ) ) {
CommentRatingFieldPlugin::SaveRating( $comment_id );
}
}
}
}

add_action( ‘wpuf_add_post_after_insert’, ‘wpufe_insert_first_comment’ );
[/php]

For the use of this snippet, insert this code into your themes functions.php. You need to add a custom field into your form with the meta key `comment`. Also add a custom field (dropdown) with the key `crfp-rating`. That should work.

April 21, 2013 at 3:54 pm 2646
jlc jlc

Thank you so much!

Amazing plugin, amazing support!

April 21, 2013 at 4:06 pm 2647
Tareq Hasan Tareq Hasan

If you like, I would be glad if you say something here 🙂

Viewing 4 Posts - 1 through 4 (of 4 total)