Skip to content

Instantly share code, notes, and snippets.

@Acephalia
Created February 22, 2024 07:24
Show Gist options
  • Save Acephalia/65fd4cb351cdbfd49c1bf4c25ff6fcab to your computer and use it in GitHub Desktop.
Save Acephalia/65fd4cb351cdbfd49c1bf4c25ff6fcab to your computer and use it in GitHub Desktop.
Wordpress Submit Sendfox Form On User Registration
// Wordpress Submit Sendfox Form On User Registration by u/acephaliax
// This snippet will submit a sendfox form of your choosing anytime a new user signs up via a non standard resgstarion method on your wordpress site. Replace the form details below with the form from your dashboard.
function auto_submit_sendfox_form_on_user_register( $user_id ) {
$user_info = get_userdata( $user_id );
// Prepare the data to be sent
$body = array(
'first_name' => $user_info->first_name,
'last_name' => $user_info->last_name,
'email' => $user_info->user_email,
// Add any other fields as necessary
);
// Set the URL where the request is to be sent
$url = 'https://yourformsubmiturl';
// Use wp_remote_post to submit the form data
$response = wp_remote_post( $url, array(
'method' => 'POST',
'body' => $body,
'headers' => array(),
'sslverify' => false,
));
// Optional: Log response for debugging
if ( is_wp_error( $response ) ) {
$error_message = $response->get_error_message();
// Log error message
} else {
// Log successful submission
}
}
// Hook the function to the user_register action
add_action( 'user_register', 'auto_submit_sendfox_form_on_user_register', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment