WordPress Plugin Setting’s POST

I’ve developed a few plugin for WordPress. Currently I’ve not been able to replicate the way wp save settings. I’ve a setting page which I learned from a tutorial. It POST to option.php, and wp take care of saving the data.

But I have some custom option page which require more complex handling. Basically I wanted to POST some data to my own php, then redirect back to the original page/url after handling. I can’t find a “proper” way to redirect correctly, i.e. without load the whole page then redirect using javascript.

Read More

Currently I use GET with add_query_arg(), the url will display the data that I passed. Using POST will trigger a redirect prompt when refreshed.

Is there a built in wp function that does it automatically? OR If I were to POST to option.php, how should I access the data without it handling automatically?

EDIT: Example of one of the complex page would be like this:

I assign a usermeta to some users which we would call SU (SpecialUser). To ease the job of admin, I have a page to display the list of users with a column showing whether they are SU. The text in that column of each row is a link which if clicked, will toggle the state of SU for that user. Currently I use GET, to pass the id of the user and also action to be carried out. Then page itself will detect, if both action and id is valid, the state of the user is toggled. At the same time, the updated result is displayed. The GET query remain at the URL

What I would really like to do is to use POST, pass the id and action to the same page, then toggle the state but not displaying anything, then “redirect” back to the page displaying the updated user list. What I’ve tried earlier while implementing this is to use javascript to redirect the page, but this means it will have to load the whole page before the javascript can be executed. It’s not resource friendly. I would like it to work much like how the Settings API would.

Sorry for the long explaination. I’m sure there’s a term to what I wanted to do, but I’m not sure what it is.

Thanks

EDIT: It’s more or less like the Plugin page, when you activate/deactivate the plugin. The plugin page is using GET. The problem I have is actually redirecting, so GET or POST shouldn’t matter.

Related posts

Leave a Reply

2 comments