No addon for Forminator forms, how to integrate?

[ad_1]

Okay, was able to piece this together looking at the plugin code. The documentation is not very helpful for this, unfortunately. It’s quite simple, so it would be nice if it were added.

As mentioned, we can hook into Forminator to get the info when the form is submitted. Then we can start a Newsletter subscription with this code. In the interest of completeness, I’m including the Forminator filter hook. However, the part inside the ‘foreach’ loop could be used anywhere.

function my_form_submit_field_data( $field_data_array, $form_id ) {
// iterate through submitted form array
foreach ($field_data_array as $k => $v) {
	// do stuff to retreive info: $name and $email
	$action='subscribe';
	// instantiate the method
	$newsletter = Newsletter::instance();
	// check if newsletter user exists
	$user = $newsletter->get_user($newslemail);
	if (!$user) {
		$user['name'] = $name;
		$user['email'] = $email;
		$user['status'] = 'C';
		$user = $newsletter->save_user($user);
	} else {
		echo "User email already exists<br>";
	}
}
return $field_data_array;
}
add_filter('forminator_custom_form_submit_field_data', 'my_form_submit_field_data', 10, 2);
  • This reply was modified 3 seconds ago by jamminjames. Reason: added Forminator hook

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer