remove $_GET-parameter from WP_List_Table::tablenav

I’m using URL parameters as actions links within a custom WP_List_Table for users like so:

http://domain.com/wp-admin/users.php?page=account-expiration-status&do_action_xyz&email=email%40domain.com&_wpnonce=xyz

Within the parent class, I’m checking for the existence of

array_key_exists( 'do_action_xyz', $_GET )

to trigger the appropriate functions.

This works fine, but unfortunately the $_GET-parameters get added to the paginations links of the table as well. This causes the action to get triggered twice when using the tablenav to browse forward or backward in the table.

I’ve tried removing the $_GET-parameters right after executing the desired action with both:

unset( $_GET['do_action_xyz'] );

and

remove_query_arg( 'do_action_xyz' );

but WordPress still adds them to the pagination links of the table.

Can anyone help me to remove the query arg correctly after executing the action?

Solutions Collecting From Web of "remove $_GET-parameter from WP_List_Table::tablenav"

You should consider the POST request method for your action.

Otherwise you might try to hijack the set_url_scheme filter with:

add_filter( 'set_url_scheme', 'wpse_remove_arg' );

function wpse_remove_arg( $url )
{   
    return remove_query_arg( 'do_action_xyz', $url );
}

Then you could try to narrow the scope and only run this on the corresponding table page. Further you could limit it’s affect by adding it as close to the table pagination list as possible and then remove it with:

remove_filter( 'set_url_scheme', 'wpse_remove_arg' );

as soon as possible.