WordPress.org

Forums

Contact Form 7
[resolved] Howto get the form id (5 posts)

  1. elliskot
    Member
    Posted 1 year ago #

    Hi all, i search for this but without success.

    I need to get the form id, in the file contact-form-7/scripts.js to select a different operation for different form.
    How can i get the form id?

    Thank you

    Ellis

    http://wordpress.org/extend/plugins/contact-form-7/

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 1 year ago #

    By looking the HTML source? I'm not sure if I understand what you need.

  3. elliskot
    Member
    Posted 1 year ago #

    Hi, you're right, sorry.
    I extend CF7 to redirect to paypal for donations.

    The problem: i have 2 forms, and now the second redirect too to paypal. This is a problem cause it is only a contact form.
    In the scripts.js:

    if (1 == data.mailSent) {
        ro.addClass('wpcf7-mail-sent-ok');
        if (typeof afterFormSubmit == 'function') afterFormSubmit(); //added this
        if (data.onSentOk)
            $.each(data.onSentOk, function(i, n) { eval(n) });
    } else {

    then

    function afterFormSubmit() {
        $("div.wpcf7 > form").unbind('submit.form-plugin');
        $("div.wpcf7 > form").attr('action', 'https://www.paypal.com/cgi-bin/webscr');
        $("div.wpcf7 > form").submit();
    }

    I hadn't realize that all the forms took the same behavior :(
    I simply think if i get the id of the form, i could change the if statement to call afterFormSubmit(), only for the form i need it.

    Thank you
    And sorry for my english

  4. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 1 year ago #

    How about make a parent <div> with specific id attribute and put [contact-form-7 xxx] shortcode inside it, then use the id of the parent div in your js function?

  5. elliskot
    Member
    Posted 1 year ago #

    Hi, i solved ad you said. Sorry but js and php are not in my skills (just a bit).

    I add a div with id property to the page. In js, i check the length of the searched div.

    It works like a charme.

    Thank you

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic