Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Anna Johansson on "Prevent wp_redirect on edited tag"

$
0
0

What I'm trying to achieve is that when a user edits an existing term and submits the changes he or she isn't redirected back to the overview of terms on edit-tags.php, but instead stays on the same term edit screen.

Simply put, what I want is to change the $location to be the

$_REQUEST['_wp_http_referer']
value.

I've tried this but I can't get it to work coherently (and also it relies on private functions and classes so I was hoping to find a more future proof solution):

function hip_stay_on_edit_term_page() {
	if( function_exists( '_get_list_table' ) && class_exists( 'WP_Terms_List_Table' ) ) {
		global $pagenow;
		if( $pagenow == "edit-tags.php" ) {
				$hip_WP_Terms_List_Table = _get_list_table( 'WP_Terms_List_Table' );
				switch ( $hip_WP_Terms_List_Table->current_action() ) {
					case 'editedtag':
						wp_redirect( $_REQUEST[_wp_http_referer] );
						exit;
					break;
				}
		}
	}
}
add_action( 'wp', 'hip_stay_on_edit_term_page', 9999 );


Any ideas on how to solve this would be greatly appreciated!


Viewing all articles
Browse latest Browse all 8245

Trending Articles