Forked from davidzack/gist:194f37444c9d68630308ee416381ef61
Last active
February 7, 2021 15:00
-
-
Save markjaquith/1688435ebb619897f685034b7f6bf27a to your computer and use it in GitHub Desktop.
If user is logged in, and on the front page, redirect to /?firstName=FIRST&lastName=LAST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
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 ); | |
exit; | |
} | |
} | |
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