redirect_to paramater
-
I added the
redirect_toparameter to the switch URL as described in the FAQ, but it doesn’t work.
Whether I include the parameter or not, it redirects to home_url() or admin_url(). Are there any other required parameters or settings?if ( method_exists( 'user_switching', 'maybe_switch_url' ) ) {
$url = user_switching::maybe_switch_url( $target_user );
$my_page = 'slug_of_target_page';
if ( $url ) {
// Redirect to the home page after switching:
$redirect_to = home_url( '/' ) . $my_page;
printf(
'<a href="%1$s">Switch to %2$s</a>',
esc_url( add_query_arg(
'redirect_to',
rawurlencode( $redirect_to ),
$url
) ),
esc_html( $target_user->display_name )
);
}
}
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.