WordPress: Bloquear wp-admin a no administradores

/**
 * Hide admin bar for non-admins
 */
function js_hide_admin_bar( $show ) {
	if ( ! current_user_can( 'administrator' ) ) {
		return false;
	}

	return $show;
}
add_filter( 'show_admin_bar', 'js_hide_admin_bar' );

/**
 * Block wp-admin access for non-admins
 */
function ace_block_wp_admin() {
	if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
		wp_safe_redirect( home_url() );
		exit;
	}
}
add_action( 'admin_init', 'ace_block_wp_admin' );

WordPress: Bloquear wp-admin a no administradores Leer más »