Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8695525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:03:36+00:00 2026-06-13T01:03:36+00:00

Case: I have a form in the page which enables users to add certain

  • 0

Case: I have a form in the page which enables users to add certain values in a simple text file. Now I want to redirect to the same page after values have been added successfully.

The read/write code all works great, I even put redirection code but this would display warning that header information is already sent.

Headers I tried:

header("Location: some_url_here_in_same_site");
wp_redirect("some_url_here_in_same_site");

My Form code:

if(isset($_POST['txtName'])}

    // form validation code here
    if(successful)
        wp_redirect("some_url_here_in_same_site");

}

PROBLEM:

  • how can we do redirection in wordpress after form submission in our plugin?
  • ob_start wonb’t work, so don’t suggest me this either
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:03:37+00:00Added an answer on June 13, 2026 at 1:03 am

    Ok I managed to do it using Hooks. I did redirection using the code below. Note that the form action is set to admin-post.php

    <form action="admin-post.php" name="frmHardware" id="frmHardware" method="post">
        <!-- form elements -->
        <!-- Essential field for hook -->
        <input type="hidden" name="action" value="save_hw" />
    </form>
    

    Then in my plugin’s main file, I added the following:

    add_action('admin_init', 'RAGLD_dashboard_hardware_init' ); // action hook add/remove hardware
    

    Where, the function definition is as follows:
    Also note that the first argument is derived from admin_post which is a reserved word is combined with the action hidden field in the form above.

    function RAGLD_dashboard_hardware_init() {
        // checking for form submission when new hardware is added
        add_action( 'admin_post_save_hw', 'RAGLD_process_hw_form' );
    }
    

    after the evaluation that form has been submitted in above add_action, function RAGLD_process_hw_form will be called which is meant to validate form entries and take actions/redirections accordingly.

    function RAGLD_process_hw_form() {
        if (form_is_validated) {
            wp_redirect( add_query_arg( array('page' => 'ragld/edit-hardware', 'action'=> 'InvalidData'), admin_url() ));
        } else {
            //do something else
        }
    }
    

    This is the solution I could think of for the time being, you can suggest your answers if you feel they are more effective.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form which contains a checkbox field. On page load I want
I have a form which allows users to comment on a page, however they
I have a case where i want to submit a form and get the
I have an HTML form that submits to a PHP page which initiates a
I have a form which posts data to the same page. Based on the
I have a form page in which either an INSERT or an UPDATE query
Hi I have a search results page which returns queries form the database using
I have a form which collects basic user information. On the subsequent page it
I have a picture uplaod tool which reloads the page (which contains a form)
I'm using Struts2+Hibernate. I have a form in a JSP page, in which there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.