Home Forums Plugin Support WP User Frontend Pro From "textarea field" to "Comments"

This topic is: resolved

This topic contains 4 replies, has 2 voices, and was last updated by  Tareq Hasan 5 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2633

    jlc
    Participant
    Post count: 5

    Hello,

    ¿It's possible to pass info from the “textarea form field” to a “Comment” for that post?

    Thank you.

    #2643

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #2644

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #2646

    jlc
    Participant
    Post count: 5

    Thank you so much!

    Amazing plugin, amazing support!

    #2647

    Tareq Hasan
    Keymaster
    Post count: 2831

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

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘From "textarea field" to "Comments"’ is closed to new replies.