• Hello.
    I have widget that is prepared for making appointment and I need to redirect to another site after submission. But as I never dealt with WordPress nor php I have big trouble with determine what function exactly is responsible for form submission. Form action is connected with
    /wp-admin/admin-ajax.php

    And at the end I have normal form submit button. That’s all I found. Where should I search for a form submission function.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Sorry for the slow reply. There is no function that actually handles form submissions, that is handled by the browser itself, though functions might handle the resulting request from the browser. Where the form is sent depends on the action attribute of the <form> tag. If it is not specified, the form goes to the same code page or is handled by javascript.

    If the request in your case is going to admin-ajax.php then the submission is being handled by javascript or jQuery. In such a case, the function that handles the resulting request is an action callback. (Assuming the code is following accepted WP AJAX techniques) The action tag is in part determined by the “action” field specified by the jQuery function making the request. Either “wp_ajax_” or “wp_ajax_nopriv_” is prepended to the action value, depending on if the user is logged in or not.

    The add_action() function is used in code somewhere to add the callback function to the resulting action tag. I fear this explanation will make little sense. Perhaps I can simply explain how to hunt down the handling function in code. It would help greatly if you can narrow down the code in which you need to search, such as a specific plugin or theme.

    First look for a clue to which javascript or jQuery function is handling the submission. It may call .ajax() or .post() methods to do this. There will be an ‘action’ data item specified somewhere, this value is what either “wp_ajax_” or “wp_ajax_nopriv_” is prepended to.

    Once you know the action tag, look in PHP code for a call to add_action() involving the tag. The second parameter will be the callback function actually handling the request.

    Apologies if this is too confusing, I’m unsure how to simplify it more.

    Dion

    (@diondesigns)

    Do you want to submit the form to another site, or do you want to process the form in WordPress and then, based on the submitted information, send the user to another site?

    The solution will be very different depending on your answer to the above question.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Redirect after form submission’ is closed to new replies.