Skip to content

Instantly share code, notes, and snippets.

@alfredo-wpmudev
Created April 6, 2024 21:16
Show Gist options
  • Save alfredo-wpmudev/69cdba87614eb667042243aa4c043359 to your computer and use it in GitHub Desktop.
Save alfredo-wpmudev/69cdba87614eb667042243aa4c043359 to your computer and use it in GitHub Desktop.
Hustle Popup and Flodesk integration to trigger events after submit the form succesfully
jQuery( document ).ready(function() {
//This is the ID of the Flodesk form, it's on the HTML embed code
var myFlodeskFormID = "fd-form-66117b239213c48f3b2c8798";
//The Hustle Popup ID, can be found in the URL while editing it or in the shortcode
var myHustlePopupID = 12;
//The time you want to wait after the form is submited to check if was a success
var myWaitingTimeAfterSubmit = 3000;
function setNeverSeeAgain(module_id){
var cookieName = "inc_optin_never_see_again-popup-"+module_id;
const cookieValue = module_id;
const d = new Date();
d.setTime(d.getTime() + (365*24*60*60*1000));
const cookieExpires = d.toUTCString();
const cookiePath = "/";
const cookieDomain = window.location.hostname;
document.cookie = `${cookieName}=${cookieValue}; expires=${cookieExpires}; path=${cookiePath}; domain=${cookieDomain}`;
}
jQuery("#"+myFlodeskFormID+" form" ).on( "submit", function( event ) {
setTimeout(() => {
//Checking if the Success message is visible
if(jQuery("#"+myFlodeskFormID+" .fd-form-success").is(":visible")){
//If you want to never show the Popup again
setNeverSeeAgain(myHustlePopupID);
//To reload the page
//window.location.reload();
//To Close the Popup
jQuery('.hustle-button-close').click();
}
}, myWaitingTimeAfterSubmit);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment