Ninja Forms

Ninja Forms 3.0 or higher

Ninja Forms 3.0 and higher is supported.

Initial setup

  1. Ensure AffiliateWP version 1.9+ is installed and activated.
  2. Ensure Ninja Forms version 3.0+ is installed and activated.
  3. To enable integration with Ninja Forms, go to Affiliates → Settings → Integrations and check the box next to Ninja Forms. Click Save Changes.
  4. In the WordPress admin menu, go to Forms and click the Add New button.
  5. Click on the “Just click here and select the fields you want.” link to start building your form. Add at least a couple of fields (for example, First Name and Email).
  6. You will also be required to add a Submit button.
  7. To enable referrals to be generated for this form, go to the Emails & Actions tab. Click the Plus (+) icon in the bottom right corner of the page.
  8. Click the Add Referral option under the Installed section. This will add a new Action called "Add Referral" to the form. New "Add Referral" action added:
  9. When the Add Referral action has been added, your form will now generate $0.00 referrals for affiliates who refer form submissions.
  10. If you would like AffiliateWP to calculate a specific referral amount for each form submission, click on the cog icon next to Add Referral to edit the action. You'll see some new options appear on the right-hand side of the page. 
  11. To calculate a specific referral amount for each submission, you will need to add a Product field with a value of your choice, as well as a Total field for the final calculation. 
  12. AffiliateWP will use the global Referral Rate and Referral Rate Type (as set in Affiliates → Settings → General) to calculate an affiliate commission based on the amount you enter in the Product field. The Total field will calculate the total price for the form, and subsequently, how much affiliate commission will be calculated.

    Example of setting a Flat Rate referral rate: If Ninja Forms is your only integration with AffiliateWP and you wish to generate a $2.00 affiliate commission for a form submission, you could enter a Flat Rate of “2" in AffiliateWP’s General settings. Now, when an affiliate refers a visitor, and the visitor completes and submits this form, a commission of $2.00 will be generated for the affiliate.

    Example of setting a Percentage referral rate: If you wish to use a Percentage referral rate type (e.g. you have multiple integrations and/or forms, or you would prefer to work with percentages), and you wish to generate a $5.00 affiliate commission on every submission of this particular form, you could set a global Referral Rate of 20% in AffiliateWP's General settings, and enter “25.00" in the Price field for the Product section of the form. When an affiliate successfully refers a visitor, and the visitor completes and submits this form, a commission of $5.00 will be generated for the affiliate.

Final steps: Mapping the form with merge tags

If you have set up your form to calculate a specific referral rate based on Product and Total fields, follow the steps below.

  1. Click on the click on the cog icon next to Add Referral to edit the action. You'll see some new options appear on the right-hand side of the page.
  2. In the Total field, click on the menu icon. Select the corresponding merge tag from your form. As per the below example, the merge tag is Total

  3. For any other fields in your form, click on the menu icon. Select the corresponding merge tag from your form. As per the below example, we've merged the email field in the form with the Email merge tag. Repeat this step as necessary to map your form.
  4. In the Description field, enter some text that clearly describes where the referral came from, such as “My Contact Form” or “My First Product”, etc.
  5. Click the Done button.
  6. Click the Publish button.
  7. If you haven’t already given your form a title, you'll be prompted to do so. Give your form a title and click Publish again.
Your form is now ready to insert on any page or in any post! Now, when an affiliate refers someone to your site, and that person completes this form, the affiliate will be awarded a commission based on what you have set in the form and/or AffiliateWP’s General settings.

Older versions of Ninja Forms

From version 1.7 onwards, you can now enable and disable referrals on  any Ninja Form. Once the integration has been enabled:

  1. Go to the Settings tab of your form
  2. Open the Restrictions section
  3. Enable the Allow Referrals checkbox
  4. Click Save

Once enabled, AffiliateWP will automatically generate a referral each time the customer is referred by an affiliate and submits a form.

In   Affiliates → Referrals, the Reference column refers to the entry ID in Ninja Forms:

Clicking on the  Reference column will take you directly to the entry details page in Ninja Forms.

That's it, you're done!

The old, old method

Note: Prior to version 1.6, Ninja Forms was only minimally supported. The old integration method is described below for reference or if you need to use it for any reason. If you use the method below, leave the  Ninja Forms box unchecked in Affiliates → Settings → Integrations.

This document will walk you through how to setup simple referral tracking with Ninja Forms. It uses the same function that the [affiliate_conversion_script] shortcode uses and demonstrates how you can pass dynamic values into the function.

Most of the code shown below can be used to help you set up dynamic values for any other form plugin or system that you are using.

First, set up your Ninja Form with the fields you require. The total field is optional and if you choose not to have it, the referrals will simply be created with a zero value.

8544-1

If you are wanting the amount to be calculated in the referral, take note of the Field ID for your total field:

8544-2

And this is what the form looks like on the front-end:

8544-ninja-form

Second, set up the form to redirect to another page upon submission. You can configure this option under the Notifications tab. This will be the page that users land on after submitting the form.

8544-3

Third, copy and paste the following code (mind the opening PHP tags) into your child theme's functions.php or custom plugin. If you're using a total field, replace the $total_field_id variable below with the Field ID of your total field (shown in the second image above).

That's it! When a referral link is used and the customer fills out your Ninja form, a new referral will be created.