[Hustle Pro] Prevent popup open after form submit

We are using the Hustle Pro plugin, and we’ve currently got a pop-up with an embedded gravity form. It works great, but we realized that people who are filling out the gravity form are being prompted again when they go to a new page or open another session. Is there any supported way to work around this or would it require a more custom approach? Basically, we want the popup to NOT OPEN for users who have already submitted the form. Please advise.

  • Felipe Santos
    • WordPress Warrior

    Hi jchura ,

    I hope that you’re having a great day!

    I can see a way for doing something like that. Could you please try doing it the following way and let me know if that makes sense?

    The idea would be adding a user role to the users that have filled the form, then excluding the pop-up for this specific user role.

    1. Adding user role when the user fills the form

    In this case, you could check the following snippet: https://docs.gravityforms.com/gform_user_updated/#add-additional-role

    Have in mind that you would need change from “1” to the form ID that you’ve created using Gravity Forms and also change from “custom_role” to the user role that these users would have.

    You could create and manage user roles using a plugin like User Role Editor.

    2. Adding User Role visibility condition on Hustle Pro

    In this case, please go to the pop-up settings, then Visibility, and press “+ Add Conditions”.

    Select “User Roles” and proceed adding this condition. After that, all that you have to do is select “Only these” and choose the ones that the pop-up should show up (excluding the one that you created).

    You can see something like that:

    [attachments are only viewable by logged-in members]

    Best regards,
    Felipe

  • LDM
    • Flash Drive

    Hey Felipe!

    That’s brilliant, thank you! The details on the user role were a little different in practice (we don’t have the user registration add-on), but you definitely led me down the right path. :slight_smile:

    However, I realized this will only impact users who are logged in– is there a way to refrain from showing it to users who aren’t logged in but submitted the form already? Something along the lines of setting a cookie comes to mind, but not seeing any way I can limit the pop-up based on a setting like this. Let me know what you think!

    Thanks again!
    Jessica

  • Felipe Santos
    • WordPress Warrior

    Hi jchura ,

    I’m sorry about the add-on suggestion, but I’m happy that at least it has provided a path somehow.

    Have you decided using the add-on? In this case, don’t you think that would make sense registering all those subscribers as users?

    I’ve escalated your ticket to our Second Line Support (SLS). They are going to have a closer look into your situation, and we’ll provide updates as soon as possible.

    It might take a little more time than the usual as they have to deal with some more complex situations.

    Please have in mind that there are some cases that it could get too complex, and we could need to ask you to move for custom development in those cases.

    Registering those users could be great as it would also work if they access using a different browser, but anyway the SLS team is possibly going to provide alternatives, so I recommend you to wait just a little bit. :slight_smile:

    Best regards,
    Felipe

  • LDM
    • Flash Drive

    Thanks for the update, Felipe!

    In our situation, gathering info through this pop-up is a vital part of the process, but one that we want to take place before they’ve necessarily signed up for an account, so I don’t see a way around it in this case. If we’re able to do some sort of limiting based on cookies we can set for users who have submitted the form previously, that would be ideal. Thanks so much for passing it along!

  • Maciej Palmowski
    • Recruit

    Hi jchura

    I created a extra cookie check condition for Hustle – https://gist.github.com/wpmudev-sls/ca7f7ab5695ce0d3ba692a0524248dc6 – it’s a mu-plugin so you just have to download it and put into mu-plugins folder (create it if it doesn’t exist).

    Than in Hustle you there should be a new condition called Cookie Set. In the textarea you can enter enter either just cookie names – than it will check if cookie exist or you can enter them like this: name|value so it will check if cookie called “name” exists and it’s value is “value”.

    I’m not sure if Gravity Forms set some cookie after sending the form – but I’ve found a snippet that looks valid:

    // Make sure to swap out {your_form_id} with the ID of the form.
    
    add_action( 'gform_after_submission_{your_form_id}', 'wpse_set_submitted_cookie', 10, 2 );
    
    function wpse_set_submitted_cookie( $entry, $form ) {
    
        // Set a third parameter to specify a cookie expiration time, 
        // otherwise it will last until the end of the current session.
    
        setcookie( 'wpse_form_submitted', 'true' );
    }

    So in theory you could just check for wpse_form_submitted cookie and it should be ok.