• Resolved jamminjames

    (@jamminjames)


    This plugin has addons for many form plugins, but not Forminator. How can we integrate it to allow form users to optin to the newsletter?

    We have a child theme, and Forminator provides many hooks. We can use one to check the submitted data for the newsletter optin, and collect their name and email. How can we proceed from there?

    Thanks for any help.

Viewing 1 replies (of 1 total)
  • Thread Starter jamminjames

    (@jamminjames)

    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 1 year, 2 months ago by jamminjames. Reason: added Forminator hook
Viewing 1 replies (of 1 total)
  • The topic ‘No addon for Forminator forms, how to integrate?’ is closed to new replies.