0

I have a normal WordPress settings page. It POSTs to options.php.

In options.php it uses wp_get_referer to redirect back to the page it came from.

I need to use remove_query_arg to remove an argument from the URL. Example:

https://www.example.com/wp-admin/admin.php?page=plugin_settings_page&tab=90

I need to remove the tab=90 part. How can I do this via options.php?

2 Answers 2

0

Ended up using jQuery to do this. There might be a better way, but this works:

jQuery("input[name=_wp_http_referer]").val('admin.php?page=plugin_settings_page')
3
  • That's really far from a good idea.
    – kaiser
    Mar 17, 2017 at 21:10
  • @kaiser - I agree, but I don't know of another way. Do you? Mar 18, 2017 at 1:28
  • Maybe you can add more than just the link you provided. Then it would be easier to show you how to fix it.
    – kaiser
    Mar 18, 2017 at 17:36
0

I would create a function that unset the tab parameter, then call that function using add_filter to filter it from the query_vars array. The example value of 20 may need to be changed depending on when the tab parameter is currently being added.

  add_filter('query_vars', 'remove_queryvars_param', 20 );

    function remove_queryvars_param( $qvars )
    {
        unset($qvars['tab']);

        return $qvars;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.