Skip Navigation

[Resolved] Actions after CRED ajax submission

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 7 years ago.

Assisted by: Christian Cox.

Author
Posts
#513569

Hi, I have a list of posts, and at the end of the list is CRED add post form. SImply, I would like the list to be refreshed (ie including the new post), and then continue displaying the (empty) cred form in case user wants to add another post. This should be done via AJAX, so that it doesn't force a page reload.

Toolset submits the form and creates the new post - no problem. If I use the "Keep displaying form" option, then nothing happens after submit success. However doesn't seem any easy way to do the list refresh (ie add new post), and to clear the form.

Is there any way of hooking into the AJAX success function?

eg 1 - by modifying the original "submit" ? (eg this means disabling the original submit, and replacing with a revised submit that includes a modified success callback. How could this be done?)

eg 2 - hooking into ajaxSuccess event? (How to uniquely identify the CRED success?)

eg 3 - overriding the standard CRED js callback function. How would I do this?

Also it seems like I can use the cred_submit_complete hook in CRED API, and using shortcode to generate the desired html for the new post. How to add this to the add the updated post html to the AJAX call result?

#513791

Hi, I'll try to answer your questions about what we offer with CRED:

Is there any way of hooking into the AJAX success function?
The CRED PHP API is limited to backend events, and we don't currently provide any JavaScript API that publicly exposes front-end events. This is something lots of people have asked for, but our developers have not yet implemented. Any custom implementation developed for this purpose, e.g. listening to all AJAX events and responding accordingly for CRED events, would require custom code, which is outside the scope of the support we provide here in the forum. Sorry I don't have a good answer for you there.

Also it seems like I can use the cred_submit_complete hook in CRED API, and using shortcode to generate the desired html for the new post. How to add this to the add the updated post html to the AJAX call result?
It sounds like you would like to modify the AJAX results of a CRED submission to include the new post's saved content. Unfortunately the CRED API is not designed to allow you to modify the structure of the return object for each call type. The structure is predefined, and any modification to the structure may have unintended results. Further - I don't think it will be helpful for you since the capability to respond to AJAX events appropriately does not currently exist in CRED.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.