Support » Plugin: LH Signing » I need a text area

  • Resolved rheajap

    (@rheajap)


    Hello,

    I wrote your review!! I have one more question.

    Is it possible to give the form one additional field. I need a text-area of max 250 characters. It is not needed to make it *required since I want to ask to the subscribers to comment why they subscribe. A sort of custom field.

    So, the form wil aks first name, last name, email, Why, comment (text-area.

    I really hope you can tell me how I do that.. because then its totally suiting my needs.

    It okay if you tell me where to put in the code.. or is it a function again which i cannot make myself?

    Warm regards

    Jap

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author shawfactor

    (@shawfactor)

    This needs to be done via filters

    for example:

    firstly add the additional input to the signing form

    function your_form_handler($content, $atts, $post){

    if ($post->ID == “6515”){

    $content .= ‘<p>
    <textarea name=”your-textarea” id=”your-textarea” rows=”10″ required=”required” placeholder=”a placeholder”></textarea>
    </p>’;

    }

    return $content

    }

    add_filter( ‘lh_signing_intermediate_logged_out_form_filter’, “your_form_handler”, 10, 3);

    public function your_post_handler($user_id){

    if ($_POST[‘your-textarea’]){

    add_user_meta( $user_id, ‘your_meta_key’, sanitize_text_field($_POST[‘your-textarea’]));

    }

    }

    add_filter( ‘lh_signing_http_post_filter’, “your_post_handler”, 10, 1 );

    Easy enough to do. Any custom work let me know, my rates are reasonable.

    Pete

    Thread Starter rheajap

    (@rheajap)

    Hello,

    I tried to use your function but I get an internal server error. Code 500

    Then I noticed I had to change some values but it did not work out. I am really not good with writing functions so I am looking to the code without a sollution.

    function your_form_handler($content, $atts, $post){
    
    if ($post->ID == "285"){
    
    $content .= '<p>
    <textarea name="opmerkingen" id="opmerkingen" rows="10" required="required" placeholder="a placeholder"></textarea>
    </p>';
    
    }
    
    return $content
    
    }
    
    add_filter( 'lh_signing_intermediate_logged_out_form_filter', "your_form_handler", 10, 3);
    
    public function your_post_handler($user_id){
    
    if ($_POST['opmerkingen']){
    
    add_user_meta( $user_id, 'opmerkingen', sanitize_text_field($_POST['opmerkingen']));
    
    }
    
    }
    
    add_filter( 'lh_signing_http_post_filter', "your_post_handler", 10, 1 );

    What I did:

    Changed all the ‘ abd ” in the correct ones because they where different as the rest of my code.

    Changed post id to the id of the post with the shortcode

    Changed text area name and id,

    Changed the your-text area in the line with sanitize text field into the name opmerkingen.

    But now I do not have any clue. I think the ” your_post_handler” or ” your_form_handler” and ” your_meta_key” Should be changed with my own value but .. really I do not know.

    Or do I have to make the database table myself?

    It’s one of the last things I need to do for the website to get it live. It is a sort of protest idea against the political situation in the Netherlands. I do not know your rates but I know there is no to very less money.. .I can send you a small donation if you like

    I really hope you can help me add a text area in the form .. its also ok if it appears in all froms because I only use one. The text area’s content has to get in the database also, just like the name, last name and email.

    Can you help me once again please?

    Have a great day.

    Jap

    Plugin Author shawfactor

    (@shawfactor)

    I had a few errors in my example because I was rushing, but this code definitely works (i’ve tested it).

    You will need to change the post id of course.
    Pete

    function your_form_handler($content, $atts, $post){

    if ($post->ID == “154643”){

    $content .= ‘<p>
    <textarea name=”opmerkingen” id=”opmerkingen” rows=”10″ required=”required” placeholder=”a placeholder”></textarea>
    </p>’;

    }

    return $content;

    }

    add_filter( ‘lh_signing_intermediate_logged_out_form_filter’, “your_form_handler”, 10, 3);

    function your_post_handler($user_id){

    if ($_POST[‘opmerkingen’]){

    add_user_meta( $user_id, ‘opmerkingen’, sanitize_text_field($_POST[‘opmerkingen’]));

    }

    }

    add_filter( ‘lh_signing_http_post_filter’, “your_post_handler”, 10, 1 );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘I need a text area’ is closed to new replies.