Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to "forget" a user's saved form #31

Open
jtwebsitedesign opened this issue May 3, 2017 · 4 comments
Open

Ability to "forget" a user's saved form #31

jtwebsitedesign opened this issue May 3, 2017 · 4 comments

Comments

@jtwebsitedesign
Copy link

I'd like to create a button that "forgets" the user's saved form. For example, let's say they filled the form most of the way, and decide they want to start all over. Is that possible?

@soulseekah
Copy link
Owner

Sure. Feel free to implement and open a pull request.

@jtwebsitedesign
Copy link
Author

Great! Any chance you could point me in the right direction to make these changes?

@soulseekah
Copy link
Owner

Sure, so:

https://github.com/soulseekah/Gravity-Forms-Saved-Forms-Addon/blob/master/gravityforms-savedforms/gravityforms-savedforms.php#L115

See how the Save button is added here? You can add a Reset button in a similar way (same hook, different callback).

When the Reset button is clicked the form will be submitted, detect this and delete any user meta the user might have.

delete_user_meta( $user->ID, 'has_pending_form_' . $form['id'] );

Here's an example of how saved meta is deleted on a successful submission:

https://github.com/soulseekah/Gravity-Forms-Saved-Forms-Addon/blob/master/gravityforms-savedforms/gravityforms-savedforms.php#L202

You'll need to do the same but earlier up the hook sequence.

Let me know how it goes.

@jtwebsitedesign
Copy link
Author

Perfect, thanks! I'll let you know how it works out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants