Integrate ConvertKit & WPForms: Include custom fields

The plugin Integrate ConvertKit & WPForms lets you add ConvertKit subscribers using a WPForms form on your WordPress site.

The plugin settings let you include the user’s email (a required field) and first name (an optional field).

Any additional data you’d like to pass to ConvertKit should be added using the be_convertkit_form_args filter.

The ConvertKit API documentation provides guidance on how you should format your data. Custom fields can be added with a fields parameter, and tags can be added with a tags parameter.

Adding a custom field

Let’s say your form has three fields: First Name, Last Name, and Email. Go to Settings > ConvertKit to configure the first name and email fields.

Place the following code in your theme’s functions.php file or a core functionality plugin. This assumes the Form has an ID of 123 and the Last Name field has a Field ID of 2 (update these to match your specific IDs).

/**
 * Include custom fields in WPForms ConvertKit Form 
 * @link https://www.billerickson.net/code/integrate-convertkit-wpforms-custom-fields/
 *
 * @param array $args, the arguments passed to ConvertKit
 * @param array $fields, the fields in the current form entry 
 * @param array $form_data, data about the current form
 * @return array $args
 */
function be_wpforms_convertkit_custom_fields( $args, $fields, $form_data ) {

	// Only run on Form 123
	if( 123 != $form_data['id'] )
		return $args;

	// last name is in field 2
	if( !empty( $fields[2]['value'] ) )
		$args['fields]['last_name'] = $fields[2]['value'];

	return $args;
}
add_filter( 'be_convertkit_form_args', 'be_wpforms_convertkit_custom_fields', 10, 3 );
Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk