• Resolved alexbosch

    (@alexbosch)


    Hi;

    I’m trying to replicate this code from Contact Form 7 integration with MC4WP with WPforms:

    if ($cf7_form_id == 500) {
           $subscriber->tags[] = 'ES';
       } else if ($cf7_form_id == 510) {
           $subscriber->tags[] = 'NL';
       }

    I think the “$cf7_form_id” should be replaced with “$wpforms_form_id”, but I have problems with the Id. If I try with the number, it didn’t apply any tag. If I try with “wpforms-500” or “wpforms-form-500” it applies the first tag to any form…

    Can you please help me?

    Thank you in advance

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Kenneth Macharia

    (@kmacharia)

    Hey @alexbosch

    Thanks for reaching out!

    I suspect that you might be using the mc4wp_integration_contact-form-7_subscriber_data filter that is reserved for CF7. This filter contains a parameter for $cf7_form_id and would not work for WPForms because of scope issues.

    Please reach out to the MC4WP team and check if they have a similar filter for grabbing WPForms data.

    I hope this helps. ??

    Thread Starter alexbosch

    (@alexbosch)

    Hi Kenneth;

    Thank you for your answer.

    I already reached the MC4WP team and they recommend me to contact you. They helped me to find how to adapt the filter, but they don’t know which PHP code is needed to point to a specific WPforms form.

    As I said on my first message I found that using the code “$wpforms_form_id” I could sent a tag, but I don’t know how to point to a specific form of your plugin using PHP.

    Can you help me with that part?

    Thank you.

    Plugin Support Kenneth Macharia

    (@kmacharia)

    Hey @alexbosch

    Thanks for getting back to me.

    Would you mind testing the following code and let me know if it works for you?

    
    $form_id = $_POST['wpforms']['id'];
    if ($form_id == 500) {
       $subscriber->tags[] = 'ES';
    } else if ($form_id == 510) {
       $subscriber->tags[] = 'NL';
    }

    Thanks! ??

    Thread Starter alexbosch

    (@alexbosch)

    Hi @kmacharia

    Yes, it worked perfectly! Thank you so much!

    Plugin Support Kenneth Macharia

    (@kmacharia)

    Hey @alexbosch

    I’m glad to hear that. ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to use the form ID with PHP code?’ is closed to new replies.