Documentation / Dependencies / WP Forms

Pre-set WP Fields for Duzz


If you want to allow your site visitors to sign up for your services through your website, then you’ll need WP Forms for them to create a project (basically an account with your business). You’ll need to connect WP Forms to Duzz Custom Portal

We’ve already created a few pre-set connections for you but you’ll have to create your fields in WP Forms and connect them. Here are the steps:

  1. Create Customer Form

    First, create your customer form. You can call it “Client Form.” Then you’ll notice that the form has an ID number highlighted below:

    WP Forms menu with ID number
  2. Connect Customer Form to Duzz Next, copy that Form ID and go to the ‘Duzz Portal’ menu in your WordPress Dashboard. Go to the submenu, titled ‘WP Forms Client’ where you’ll notice the form_id Field Value here:

    Duzz connection to WP Forms
  3. Create fields in WP Forms Next, go back to your WP Forms form you created for your customer. And add all the fields you want. You’ll want to get your customer IP address for security purposes, so create a hidden field called ‘customer_ip’ and go to the Field Options for that field and click on ‘Advanced’ and add the smart tag {user_ip} in the Default Value highlighted here:

    Create hidden fields in WP Forms

    Hidden fields should always have a pre-set default value otherwise there is no point to a hidden field. Hidden fields are also only available with the paid version of WP Forms. If you are using the Basic version, these are your field options:

    Field options in WP Forms

    Make sure to get the Field ID for every field like your Customer Name (‘customer_name’) which you can see has a value of #1 here:

    WP Forms menu showing the field ID highlighted
  4. Create fields in WP Forms

    Next, after copying that Field ID value, go back to the Duzz Portal admin settings menu and go to ‘WP Forms Client.’ Since you just copied the value for Customer Name paste that into the Field Value for ‘customer_name.’ As you can see in this example the value is 1 here:

    WP Forms Field ID for Duzz

    Be sure to paste the values for all fields you want to use so that your customer data gets properly saved. If you don’t want to use that field, if you try saving it as blank you’ll get an error, so just leave the default value as it doesn’t effect anything.

Filter: Connecting custom WP Forms fields

This is an advanced option for developers. You will need to know how to access your core WordPress files either through your hosting provider or through FTP. Then you’ll need to create a child theme with a functions.php file to add PHP functions. If you don’t know how to do this, you could risk breaking your site, so try on a test site first.

If you’ve added additional custom fields in your WP Forms, you might want to integrate this data into the Duzz Custom Portal. But as you can see right now, Duzz Custom Portal doesn’t have a way to add your additional fields to the current list of connections. Instead you’ll have to use filters with a PHP function to add custom fields. By extending the Duzz Custom Portal using the provided filters, you can ensure that when your customers submit a form, the new custom field data is also added to their project seamlessly.


How to integrate additional custom fields:

In this example, let’s pretend you want to add a field called ‘your budget’ so your customers can enter their desired budget for their project with you. Follow the steps below to ensure your additional custom fields are integrated with the Duzz Custom Portal:

  1. Identify Your Field Number:

    Firstly, you need to determine the ID or field number of your new custom field in WP Forms. This number is usually seen in the field settings when you add a new field to your form. You can see the field ID #53 highlighted during field creation here:

    WP Forms menu showing the field ID highlighted
  2. Use the Provided Code:

    We’ve provided a code example below. This code connects your additional custom field to the Duzz Custom Portal by using a filter hook.

    PHP
    
    add_filter('duzz_extend_field_numbers', 'my_custom_field_numbers_extension', 10, 4);
    
    function my_custom_field_numbers_extension($field_numbers, $fields, $form_data, $entry_id) {
        
        $field_numbers['your_custom_field_name'] = your_field_number;
    
        return $field_numbers;
    }
    

    Replace your_custom_field_name with the name of your custom field and your_field_number with the actual number or ID of your field.

  3. Modify and Add the Code:

    Modify the code to replace the placeholder field name (‘pricing_plan’ in the example) and the number (52 in the example) with your custom field’s name and its number. Then, add this modified code to your theme’s functions.php file or a custom functionality plugin.

    Here is an example of how I connected the WP Forms fields to Duzz Custom Portal. The field ‘pricing_plan’ has a WP Forms field ID of 52, the ‘due_date’ field has a WP Forms field ID of 78, and the ‘customer_budget’ field has a WP Forms field ID of 89:

    PHP
    
    add_filter('duzz_extend_field_numbers', 'my_custom_field_numbers_extension', 10, 4);
    
    function my_custom_field_numbers_extension($field_numbers, $fields, $form_data, $entry_id) {
        
        $field_numbers['pricing_plan'] = 52;
        $field_numbers['customer_budget'] = 53;
        $field_numbers['due_date'] = 68;
        return $field_numbers;
    }
    

    Of course these are just examples and any field you add to your WP Forms form will need to be added here with its matching WP Forms field ID.


Final Notes:

After adding and customizing the code, any submission from your WP Forms containing the new custom field will automatically have its data added to the Duzz Custom Portal’s project. This ensures seamless data integration without any manual data transfer.