Skip to content

Instantly share code, notes, and snippets.

@sareiodata
Created November 5, 2012 15:20
Show Gist options
  • Save sareiodata/4017732 to your computer and use it in GitHub Desktop.
Save sareiodata/4017732 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Profile Builder Custom Page Title on Single User
Plugin URI: http://cozmoslabs.com
Description: Filter wp_title on the Single User Listing
Author: Cristian Antohe
Version: 1.0
Author URI: http://cozmoslabs.com
*/
add_filter( 'wp_title', 'wppb_custom_page_title', 10, 3 );
function wppb_custom_page_title($title, $sep, $seplocation){
$singleUserListing = false;
if (isset($_GET['userID'])){
$singleUserListing = true;
$userID = $_GET['userID'];
$user = get_user_by('id', $userID);
$title = $user->first_name . ' ' . $user->last_name . ' ';
if ($title == ' ') { $title = $user->display_name . ' ';}
}else{
$userID = get_query_var( 'username' );
if (!empty($userID)){
$singleUserListing = true;
if ( is_numeric($userID)){
$user = get_user_by('id', $userID);
$title = $user->first_name . ' ' . $user->last_name . ' ';
if ($title == ' ') { $title = $user->display_name . ' ';}
} else {
$user = get_user_by('login', $userID);
$title = $user->first_name . ' ' . $user->last_name . ' ';
if ($title == ' ') { $title = $user->display_name . ' ';}
}
}
}
return $title;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment