Ended up on a project with a Wordpress site. I am trying to post data from a form made with WPforms to an external API. Not a wordpress guy, but I read that I can hook into to action from other plugins by writing my own plugin. Here is my plugin,
<?php
/**
* Plugin Name: name
* Plugin URI: http://www.mywebsite.com/my-first-plugin
* Description: plugin to post user data from wp form
* Version: 1.0
* Author: John
* Author URI: http://www.mywebsite.com
*/
function register_lsf_mobile_user( $fields, $entry, $form_data, $entry_id ) {
$api_url = "https://lsf-development.firebaseapp.com";
$body = array(
'email' => $fields[1]['value'],
'password' => $fields[1]['value']
);
$request = wp_remote_post( $api_url, array('body' => $body) );
if (is_wp_error($request)) {
$msg = "There was an error trying to register a lsfMobile user.\n";
$msg .= 'Error returned: ' . $error = $request->get_error_message() . "\n\n";
$msg .= "The user below may need to be added to the CRM manually.\n";
$msg .= $body['name'] . ' ' . $body['email'];
wp_mail( get_bloginfo( 'admin_email' ), 'lsfMobile user registration error', $msg );
}
}
add_action( 'wpforms_process_complete_16522', 'register_lsf_mobile_user', 10, 4 );
After zipping, uploading/installing, and then activating the above custom plugin I try to test it by embedding my wp_form in a private page and entering and submitting data. However, my action hook doesn't seem to be called. I tried doing the echo " alert("...")