ControlledChaos
2/7/2017 - 7:59 PM

Redirect WordPress user from the Customizer to another page, such as a Theme Options page.

Redirect WordPress user from the Customizer to another page, such as a Theme Options page.

<?php
/**
 * This example redirects by user ID
 * to a theme options page, under the
 * Appearance tab, with slug theme-info.
 *
 * Replace with your redirect page
 */

function ccd_customizer_redirect() {
	global $pagenow;
	$user_id = get_current_user_id();

	if ( $user_id == 0 && $pagenow == 'customize.php' ) {
		wp_redirect( admin_url( '/themes.php?page=theme-info', 'http' ), 301 );

		exit;
	}
}
add_action( 'admin_init', 'ccd_customizer_redirect' );

?>
<?php
/* This example redirects by user role
 * to a theme options page, under the
 * Appearance tab, with slug theme-info.
 *
 * Replace with your redirect page
 */

function ccd_customizer_redirect() {
	global $pagenow;

	if ( current_user_can( 'manage_options' ) && $pagenow == 'customize.php' ) {
		wp_redirect( admin_url( '/themes.php?page=theme-info', 'http' ), 301 );

		exit;
	}
}
add_action( 'admin_init', 'ccd_customizer_redirect' );

?>

WordPress Customizer Redirect

WordPress Snippet