Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
If user is logged in, and on the front page, redirect to /?firstName=FIRST&lastName=LAST
function home_page_first_last_name_redirect() {
if ( is_front_page() && is_user_logged_in() && ! isset( $_GET['firstName'] ) ) {
$user = wp_get_current_user();
$url = add_query_arg( array(
'firstName' => $user->first_name,
'lastName' => $user->last_name,
wp_redirect( $url );
add_action( 'template_redirect', 'home_page_first_last_name_redirect' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.