Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save markjaquith/1688435ebb619897f685034b7f6bf27a to your computer and use it in GitHub Desktop.
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
<?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