-
-
Save tahmidbintaslim/bca32090645acc75852bfa177a8a1f52 to your computer and use it in GitHub Desktop.
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 | |
/* | |
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