-
-
Save pareshsojitra/c0c1e0ceaae7354558a0b8a71fa39ed4 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 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