Issue
I have WSForm Pro form management plugin installed on my Wordpress site. The plugin utilizes AJAX as the only method to post a form's data so that only the form's area is updated on submit, not the whole page. On submit I need to show-up the form's data on the same page.
What I have done. Through adding a function to functions.php of my theme I'm able to get the form's data as a session variable:
// Add action to process WS Form form data
add_action('wsf_action_tag', 'wsf_action_function', 10, 2);
// My function for action
function wsf_action_function($form, $submit) {
// Get submit value (Change '123' to your field ID)
$submit_value = wsf_submit_get_value($submit, 'field_18');
session_start();
$_SESSION['form'] = $submit_value;
// Do something with $submit_value here
// ...
}
I also added the following php-code to the page with the form to show-up the session variable above:
<?php
session_start();
$form = $_SESSION['form'];
var_dump($form);
?>
The problem. When I submit the form, nothing changes except built-in success message (as supposed with AJAX), though on page reload the submitted data is shown-up successfully. If I could have my own AJAX script, I would want to modify it slightly to reload the whole page. But since I use a third-party plugin, it's makes the task too complicated.
The question is how would I change any part of my code to show-up the form's data on submit on the same page?
Solution
Found a workaround in WSForm functionality! From "Edit Form" choose "Actions", "Add", "Redirect" and point the page's redirect to itself. Click to to see the screenshot
Answered By - lonaihal
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.