Redirecting Users In Admin To Avoid Resubmitting Information

View: New views
2 Messages — Rating Filter:   Alert me  

Redirecting Users In Admin To Avoid Resubmitting Information

by rajasekharan-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am creating a simple create, edit, update, delete [something]
wordpress plugin.
In the create screen, the user inserts something in the database and is
sent to the
confirmation message. But the data gets inserted again if the user
refreshes the page.

How do you handle this? How do you 'redirect' users to a different
location such that once they get there, the action shouldn't be
performed again if they refresh that page. I have tried using a
javascript redirect to send the user to the confirmation page but this
method
loads the administration menu items before executing the javascript.

I would like to know:

1. If there is anyway to send javascript output in the body before any
of the wordpress administration interface code is sent to the browser.
2. If it is possible to do this without javascript, if so how?

Raj Sekharan

_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: Redirecting Users In Admin To Avoid Resubmitting Information

by Austin Matzko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Oct 24, 2009 at 10:37 PM, raj <websweetweb@...> wrote:

> I am creating a simple create, edit, update, delete [something] wordpress
> plugin.
> In the create screen, the user inserts something in the database and is sent
> to the
> confirmation message. But the data gets inserted again if the user refreshes
> the page.
>
> How do you handle this? How do you 'redirect' users to a different
> location such that once they get there, the action shouldn't be
> performed again if they refresh that page.

Do what core WP does: perform the data operations before the page is
printed (say on the "admin_init" action or the like), and then use
wp_redirect() to redirect to a page with an argument that specifies
the message to show.

For example, after submitting the Settings > General page, one is
redirected to wp-admin/options-general.php?updated=true, and that
"updated" $_GET parameter is detected and the message "Settings
saved." printed.
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers