Userlisting2

‘asc’,
‘sortingNumber’=> ’25’,
‘avatarSize’ => 16,
‘allUserlisting’ => ”,
‘singleUserlisting’ => ”);
add_option(‘customUserListingSettings’, $customUserListingSettingsArg);
}
?>


Username Company Name Telephone Number Sign-up Date More
JEFFREY BOCHNER Gem Restoration Service 917-648-4539 2021-12-02 More...
warfirestar N/A 270-245-8154 2021-11-28 More...
date Patsy and Melanie www.jhqdw8.flazio.com 2021-11-28 More...
date Yvonne and Ada www.k92c.mystrikingly.com 2021-11-28 More...
Anita has sent you 4 messages www.k92c.mystrikingly.com 2021-11-28 More...
meet Eliza and Sally www.k92c.mystrikingly.com 2021-11-27 More...
meet Whitney and Debbie www.jhqdw8.flazio.com 2021-11-27 More...
date Diana and Joanna www.k92c.mystrikingly.com 2021-11-27 More...
date Dana and Candice www.jhqdw8.flazio.com 2021-11-27 More...
kseymour22 Avalon antiques 9043142812 2021-11-26 More...
Rhoda 2 and hand Rhos' 5702666388 2021-11-24 More...
JewelBox FamilyJewelBox 318628-3002 2021-11-21 More...
Carol Crockett Splendid Ltd 021311272 2021-11-16 More...
Mike NA 646 415-0432 2021-11-16 More...
bigbogy R and C rental properties 4044444690 2021-11-15 More...
Shaindy@lijodecor.com Lijo Decor 8666114438 2021-11-10 More...
Lijo Decor Lijo Decor 8666114438 2021-11-03 More...
blbest BL BEST INC. 5095340237 2021-10-23 More...
skymastre Medical Inc 4045025778 2021-10-16 More...
BOWERSJEWELRY BOWERS JEWELRY 5742692001 2021-09-22 More...
Linda Van Hagen none 4088070942 2021-09-19 More...
rainivy596@gmail.com Valcore roofing and exteriors 5418394024 2021-09-16 More...
Ray4986 Myself 2107252685 2021-09-15 More...
euroamtey@yahoo.com MTI 9173550998 2021-08-28 More...
Eva Frieden Frieden Inc 6202394139 2021-08-20 More...
1 2 3 ... 41 ... Next »   Last »»
.
Username Company Name Telephone Number Sign-up Date More
JEFFREY BOCHNER Gem Restoration Service 917-648-4539 2021-12-02 More...
warfirestar N/A 270-245-8154 2021-11-28 More...
date Patsy and Melanie www.jhqdw8.flazio.com 2021-11-28 More...
date Yvonne and Ada www.k92c.mystrikingly.com 2021-11-28 More...
Anita has sent you 4 messages www.k92c.mystrikingly.com 2021-11-28 More...
meet Eliza and Sally www.k92c.mystrikingly.com 2021-11-27 More...
meet Whitney and Debbie www.jhqdw8.flazio.com 2021-11-27 More...
date Diana and Joanna www.k92c.mystrikingly.com 2021-11-27 More...
date Dana and Candice www.jhqdw8.flazio.com 2021-11-27 More...
kseymour22 Avalon antiques 9043142812 2021-11-26 More...
Rhoda 2 and hand Rhos' 5702666388 2021-11-24 More...
JewelBox FamilyJewelBox 318628-3002 2021-11-21 More...
Carol Crockett Splendid Ltd 021311272 2021-11-16 More...
Mike NA 646 415-0432 2021-11-16 More...
bigbogy R and C rental properties 4044444690 2021-11-15 More...
Shaindy@lijodecor.com Lijo Decor 8666114438 2021-11-10 More...
Lijo Decor Lijo Decor 8666114438 2021-11-03 More...
blbest BL BEST INC. 5095340237 2021-10-23 More...
skymastre Medical Inc 4045025778 2021-10-16 More...
BOWERSJEWELRY BOWERS JEWELRY 5742692001 2021-09-22 More...
Linda Van Hagen none 4088070942 2021-09-19 More...
rainivy596@gmail.com Valcore roofing and exteriors 5418394024 2021-09-16 More...
Ray4986 Myself 2107252685 2021-09-15 More...
euroamtey@yahoo.com MTI 9173550998 2021-08-28 More...
Eva Frieden Frieden Inc 6202394139 2021-08-20 More...
1 2 3 ... 41 ... Next »   Last »»
.
Username Company Name Telephone Number Sign-up Date More
.


‘. __(‘Show/Hide Default “All-Userlisting” Code’,’profilebuilder’).’‘;?>

‘.__(‘If you wish to use a default userlisting, just copy the following code and paste it in the textarea below:’, ‘profilebuilder’).’‘;?>

<table id=”userListingTable” cellspacing=”0″>
    <thead>
        <tr>
            <th class=”userListingTableHeading1″ scope=”col” colspan=”2″><span>%%sort_user_name%%</span></th>
            <th class=”userListingTableHeading2″ scope=”col”><span>%%sort_first_last_name%%</span></th>
            <th class=”userListingTableHeading3″ scope=”col”><span>Role</span></th>
            <th class=”userListingTableHeading4″ scope=”col”><span>%%sort_number_of_posts%%</span></th>
            <th class=”userListingTableHeading5″ scope=”col”><span>%%sort_registration_date%%</span></th>
            <th class=”userListingTableHeading6″ scope=”col”><span>More</span></th>
        </tr>
    </thead>
    <tbody>
        %%extra_while_users%%
        <tr class=”tableRow” onmouseover=”style.backgroundColor=’grey’; style.color=’white’;” onmouseout=”style.backgroundColor=”; style.color=”;”>
            <td class=”avatarColumn”>%%extra_avatar_or_gravatar%%</td>
            <td class=”loginNameColumn”><span>%%meta_user_name%%</span></td>
            <td class=”nameColumn”><span>%%meta_first_last_name%%</span></td>
            <td class=”roleColumn”><span>%%meta_role%%</span></td>
            <td class=”postsColumn”><span>%%meta_number_of_posts%%</span></td>
            <td class=”signUpColumn”><span>%%meta_registration_date%%</span></td>
            <td class=”moreInfoColumn”><span>%%extra_more_info_link%%</span></td>
        </tr>
        %%extra_end_while_users%%
    </tbody>
</table>


‘. __(‘Show/Hide Default “Single-Userlisting” Code’,’profilebuilder’).’‘;?>

‘.__(‘If you wish to use a default userlisting, just copy the following code and paste it in the textarea below:’, ‘profilebuilder’).’‘;?>

%%extra_go_back_link%%
<table id=”userListingDisplayTable”>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell1″ colspan=”2″>
            <span id=”header”><strong>Name</strong></span>
        </td>
    </tr>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell2″>
            <span id=”inputName”>Username:</span>
        </td>
        <td class=”userListingDisplayTableCell3″>
            <span id=”inputValue”>%%meta_user_name%%</span>
        </td>
    </tr>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell2″>
            <span id=”inputName”>First Name:</span>
        </td>
        <td class=”userListingDisplayTableCell3″>
            <span id=”inputValue”>%%meta_first_name%%</span>
        </td>
    </tr>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell2″>
            <span id=”inputName”>Last Name:</span>
        </td>
        <td class=”userListingDisplayTableCell3″>
            <span id=”inputValue”>%%meta_last_name%%</span>
        </td>
    </tr>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell2″>
            <span id=”inputName”>Nickname:</span>
        </td>
        <td class=”userListingDisplayTableCell3″>
            <span id=”inputValue”>%%meta_nickname%%</span>
        </td>
    </tr>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell2″>
            <span id=”inputName”>Display name publicly as:</span>
        </td>
        <td class=”userListingDisplayTableCell3″>
            <span id=”inputValue”>%%meta_display_name%%</span>
        </td>
    </tr>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell1″ colspan=”2″>
            <span id=”header”><strong>Contact Info</strong></span>
        </td>
    </tr>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell2″>
            <span id=”inputName”>Website:</span>
        </td>
        <td class=”userListingDisplayTableCell3″>
            <span id=”inputValue”>%%meta_website%%</span>
        </td>
    </tr>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell1″ colspan=”2″>
            <span id=”header”><strong>About Yourself</strong></span>
        </td>
    </tr>
    <tr class=”userListingDisplayTableRow”>
        <td class=”userListingDisplayTableCell2″>
            <span id=”inputName”>Biographical Info:</span>
        </td>
        <td class=”userListingDisplayTableCell3″>
            <span id=”inputValue”>%%meta_biographical_info%%</span>
        </td>
    </tr>
</table>
%%extra_go_back_link%%

‘. __(‘You need to activate the User-Listing feature from within the “Addons” tab!’, ‘profilebuilder’) .’
‘. __(‘You can find it in Profile Builder\’s menu.’, ‘profilebuilder’).’

‘;
$userlistingFilterArray[‘addonNotActivated’] = apply_filters(‘wppb_not_addon_not_activated’, $userlistingFilterArray[‘addonNotActivated’]);
return $userlistingFilterArray[‘addonNotActivated’];
}

//the function for the user-listing
function wppb_list_all_users($atts){

$userlistingFilterArray = array();

global $wppbFetchArray;
global $roles;

$wppbFetchArray = get_option(‘wppb_custom_fields’);

//get value set in the shortcode as parameter, default to “public” if not set
extract(shortcode_atts(array(‘visibility’ => ‘public’, ‘roles’ => ‘*’, ‘meta_key’ => ”, ‘meta_value’ => ”), $atts));

//if the visibility was set to “restricted” then we need to check if the current user browsing the site/blog is logged in or not
if ($visibility == ‘restricted’){
if ( is_user_logged_in() ) {
$retVal = wppb_custom_userlisting_contents($roles, $meta_key, $meta_value);
return $retVal;

}elseif ( !is_user_logged_in() ) {
$userlistingFilterArray[‘notLoggedIn’] = ‘

‘. __(‘You need to be logged in to view the userlisting!’, ‘profilebuilder’) .’

‘;
$userlistingFilterArray[‘notLoggedIn’] = apply_filters(‘wppb_not_logged_in_error_message’, $userlistingFilterArray[‘notLoggedIn’]);
return $userlistingFilterArray[‘notLoggedIn’];

}
}else{
$retVal = wppb_custom_userlisting_contents($roles, $meta_key, $meta_value);
return $retVal;
}

}

//function to return the links for the sortable headers
function wppb_get_address($criteria){
// Concatenate the get variables to add to the page numbering string
$queryURL = ”;
if (count($_GET)) {
$first = true;
foreach ($_GET as $key => $value) {
if ($key != ‘searchFor’)
if ($key != ‘setSortingCriteria’)
if ($key != ‘setSortingOrder’) {
if ($first){
$param = ‘?’;
$first = false;
}else
$param = ‘&’;
$queryURL .= $param.$key.’=’.$value;
}
}
}

if ($queryURL == ”)
$finalQueryParam = ‘?’;
else
$finalQueryParam = ‘&’;

$searchFor = ”;
if ((isset($_REQUEST[‘searchFor’])) && (trim($_REQUEST[‘searchFor’]) != __(‘Search Users by All Fields’, ‘profilebuilder’)))
$searchFor = ‘&searchFor=’.trim($_REQUEST[‘searchFor’]);

$sortingParam = ”;
if (isset($_GET[‘setSortingCriteria’]) && ($_GET[‘setSortingCriteria’] == $criteria)){
if (isset($_GET[‘setSortingOrder’]) && ($_GET[‘setSortingOrder’] == ‘desc’)){
$sortingParam .= $finalQueryParam.’setSortingCriteria=’.$criteria.’&setSortingOrder=asc’.$searchFor;

}elseif (isset($_GET[‘setSortingOrder’]) && ($_GET[‘setSortingOrder’] == ‘asc’)){
$sortingParam .= $finalQueryParam.’setSortingCriteria=’.$criteria.’&setSortingOrder=desc’.$searchFor;
}
}else{
$customUserListingSettings = get_option(‘customUserListingSettings’);
$sortingParam .= $finalQueryParam.’setSortingCriteria=’.$criteria.’&setSortingOrder=’.$customUserListingSettings[‘sortingOrder’].$searchFor;
}

return $queryURL.$sortingParam;
}

//function to decode each sort tagname
function decode_sortTag($tagName){

global $wppbFetchArray;

if ($tagName == ‘extra_search_all_fields’){
$value = __(‘Search Users by All Fields’, ‘profilebuilder’);

if (isset($_REQUEST[‘searchFor’]))
if (trim($_REQUEST[‘searchFor’]) != $value)
$value = trim($_REQUEST[‘searchFor’]);

$setSortingCriteria = ”;
$setSortingOrder = ”;
if (isset($_GET[‘setSortingCriteria’]))
$setSortingCriteria = ‘&setSortingCriteria=’.$_GET[‘setSortingCriteria’];
if (isset($_GET[‘setSortingOrder’]))
$setSortingOrder = ‘&setSortingOrder=’.$_GET[‘setSortingOrder’];

return ‘



‘;

}elseif ($tagName == ‘sort_user_name’){
$headTitle = __(‘Username’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_user_name_filter’, $headTitle);

return ‘‘.$headTitle.’‘;

}elseif ($tagName == ‘sort_first_last_name’){
$headTitle = __(‘First/Lastname’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_first_last_name_filter’, $headTitle);

return ‘‘.$headTitle.’‘;

}elseif ($tagName == ‘sort_email’){
$headTitle = __(‘Email’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_email_filter’, $headTitle);

return ‘‘.$headTitle.’‘;

}elseif ($tagName == ‘sort_registration_date’){
$headTitle = __(‘Sign-up Date’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_registration_date_filter’, $headTitle);

return ‘‘.$headTitle.’‘;

}elseif ($tagName == ‘sort_first_name’){
$headTitle = __(‘Firstname’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_first_name_filter’, $headTitle);

return ‘‘.$headTitle.’‘;

}elseif ($tagName == ‘sort_last_name’){
$headTitle = __(‘Lastname’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_last_name_filter’, $headTitle);

return ‘‘.$headTitle.’‘;

}elseif ($tagName == ‘sort_display_name’){
$headTitle = __(‘Display Name’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_display_name_filter’, $headTitle);

return ‘‘.$headTitle.’‘;

}elseif ($tagName == ‘sort_website’){
$headTitle = __(‘Website’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_website_filter’, $headTitle);

return ‘‘.$headTitle.’‘;

}elseif ($tagName == ‘sort_biographical_info’){
$headTitle = __(‘Biographical Info’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_biographical_info_filter’, $headTitle);

return ‘‘.$headTitle.’‘;

}elseif ($tagName == ‘sort_number_of_posts’){
$headTitle = __(‘Posts’, ‘profilebuilder’);
$headTitle = apply_filters(‘sort_number_of_posts_filter’, $headTitle);

return ‘‘.$headTitle.’‘;
}else{
foreach($wppbFetchArray as $key => $value)
if ($tagName == ‘sort_’.$value[‘item_title’])
return ‘‘.$value[‘item_title’].’‘;
}
}

//function to decode the meta tags
function wppb_decode_metaTag($tagName, $object){
global $wppbFetchArray;

//filter to get current user by either username or id(default); get user by username?
$userlistingFilterArray[‘getUserByID’] = false;
$userlistingFilterArray[‘getUserByID’] = apply_filters(‘wppb_userlisting_get_user_by_id’, $userlistingFilterArray[‘getUserByID’]);

if ($tagName == ‘extra_more_info_link’){
$userData = get_the_author_meta( ‘user_login’, $object->data->ID );

$more = ”;
$url = apply_filters( ‘wppb_userlisting_more_base_url’, $val = get_permalink() );
if (isset($_GET[‘page_id’])){
$more = $url.’&userID=’.$object->data->ID;
$more = apply_filters (‘wppb_userlisting_more_info_link_structure1’, $more, $url, $object);
}else{
//do we need to add an extra slash?
$slash = ”;
if ($url[strlen($url)-1] != ‘/’)
$slash = ‘/’;
if ($userlistingFilterArray[‘getUserByID’] === false){
$more = $url.$slash.’user/’.$object->data->ID;
$more = apply_filters (‘wppb_userlisting_more_info_link_structure2′, $more, $url, $slash, $object);
}else{
$more = $url.$slash.’user/’.$userData;
$more = apply_filters (‘wppb_userlisting_more_info_link_structure3’, $more, $url, $slash, $userData);
}
}

//return ‘>“></a>‘;<br />
		return $userlistingFilterArray[‘moreLink’] = apply_filters(‘wppb_userlisting_more_info_link’, ‘<span id=‘. __(‘More…’, ‘profilebuilder’) .’‘, $more);

}elseif($tagName == ‘meta_user_name’){
$userData = get_the_author_meta( ‘user_login’, $object->data->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_user_name’, $userData, $object);

}elseif ($tagName == ‘meta_email’){
$userData = get_the_author_meta( ‘user_email’, $object->data->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_email’, $userData, $object);

}elseif ($tagName == ‘meta_first_last_name’){
$userData1 = get_the_author_meta( ‘first_name’, $object->data->ID );
$userData2 = get_the_author_meta( ‘last_name’, $object->data->ID );

if (($userData1 != ”) && ($userData2 != ”))
$userData = $userData1 .’ ‘. $userData2;
elseif ($userData1 == ”)
$userData = $userData2;
elseif ($userData2 == ”)
$userData = $userData1;
else
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_first_last_name’, $userData, $object);

}elseif ($tagName == ‘meta_first_name’){
$userData = get_the_author_meta( ‘first_name’, $object->data->ID );
if ($userData == ”)
$userData = ‘-‘;
return $userData = apply_filters(‘wppb_userlisting_extra_meta_first_name’, $userData, $object);

}elseif ($tagName == ‘meta_role’){
if (isset($object->roles[0]))
$role = ucfirst($object->roles[0]);
else
$role = ”;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_role’, $role, $object);

}elseif ($tagName == ‘meta_number_of_posts’){
$args = array(‘author’=> $object->data->ID, ‘numberposts’=> -1);
$allPosts = get_posts($args);
$postsNumber = count($allPosts);

return $userData = apply_filters(‘wppb_userlisting_extra_meta_number_of_posts’, ‘data->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_’.$value[‘item_title’], $userData, $object);
}
case “select”:{
$userData = get_user_meta($object->data->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_’.$value[‘item_title’], $userData, $object);
}
case “countrySelect”:{
$userData = get_user_meta($object->data->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_’.$value[‘item_title’], $userData, $object);
}
case “timeZone”:{
$userData = get_user_meta($object->data->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_’.$value[‘item_title’], $userData, $object);
}
case “datepicker”:{
$userData = get_user_meta($object->data->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_’.$value[‘item_title’], $userData, $object);
}
case “textarea”:{
$userData = get_user_meta($object->data->ID, $value[‘item_metaName’], true);
if ($userData != ”)
$userData = nl2br($userData);
else
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_’.$value[‘item_title’], $userData, $object);
}
case “upload”:{
$imgSource = WPPB_PLUGIN_URL . ‘/assets/images/’;
$script = WPPB_PLUGIN_URL . ‘/premium/functions/’;
$userData = get_user_meta($object->data->ID, $value[‘item_metaName’], true);
$fileName = str_replace ( get_bloginfo(‘home’).’/wp-content/uploads/profile_builder/attachments/userID_’.$object->data->ID.’_attachment_’, ”, $userData );

if (($userData == ”) || ($userData == get_bloginfo(‘url’).’/wp-content/uploads/profile_builder/attachments/’))
$retUserData = __(‘No uploaded attachment’, ‘profilebuilder’);
else
$retUserData = $fileName.’
‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_’.$value[‘item_title’], $retUserData, $object);
}
case “avatar”:{
$customUserListingSettings = get_option(‘customUserListingSettings’,’not_found’);
$avatarSize = apply_filters(‘wppb_userlisting_avatar_size’, $customUserListingSettings[‘avatarSize’]);
$avatarImage = get_avatar($object->data->ID, $avatarSize );

return $userData = apply_filters(‘wppb_userlisting_extra_meta_’.$value[‘item_title’], $avatarImage, $object, $avatarSize);
}
}
}
}
}
}
}

//function to render 404 page in case a user doesn’t exist
function wppb_set404(){
global $wp_query;
global $wpdb;
$nrOfIDs = 0;

// if admin approval is activated, then give 404 if the user was manually requested
$wppb_generalSettings = get_option(‘wppb_general_settings’);
if($wppb_generalSettings[‘adminApproval’] == ‘yes’){
$arrayID = array();

// Get term by name ”unapproved” in user_status taxonomy.
$user_statusTaxID = get_term_by(‘name’, ‘unapproved’, ‘user_status’);
$term_taxonomy_id = $user_statusTaxID->term_taxonomy_id;

$result = mysql_query(“SELECT ID FROM $wpdb->users AS t1 LEFT OUTER JOIN $wpdb->term_relationships AS t0 ON t1.ID = t0.object_id WHERE t0.term_taxonomy_id = $term_taxonomy_id”);
if (is_resource($result)){
while ($row = mysql_fetch_assoc($result))
array_push($arrayID, $row[‘ID’]);
}

$nrOfIDs=count($arrayID);
}

//filter to get current user by either username or id(default); get user by username?
$userlistingFilterArray[‘getUserByID’] = false;
$userlistingFilterArray[‘getUserByID’] = apply_filters(‘wppb_userlisting_get_user_by_id’, $userlistingFilterArray[‘getUserByID’]);

$invoke404 = false;

//get user ID
if (isset($_GET[‘userID’])){
$userID = get_userdata($_GET[‘userID’]);
if (is_object($userID)){
if ($nrOfIDs){
if (in_array($userID->ID, $arrayID))
$invoke404 = true;
}else{
$username = $userID->user_login;
$user = get_user_by(‘login’, $username);
if (($user === false) || ($user == null))
$invoke404 = true;
}
}
}else{
if ($userlistingFilterArray[‘getUserByID’] === false){
$userID = get_query_var( ‘username’ );
if ($nrOfIDs){
if (in_array($userID, $arrayID))
$invoke404 = true;
}else{
$user = get_userdata($userID);
if (is_object($user)){
$username = $user->user_login;
$user = get_user_by(‘login’, $username);
if (($userID !== ”) && ($user === false))
$invoke404 = true;
}
}

}else{
$username = get_query_var( ‘username’ );
$user = get_user_by(‘login’, $username);
if (is_object($user)){
if ($nrOfIDs){
if (in_array($user->ID, $arrayID))
$invoke404 = true;
}else{
if (($username !== ”) && ($user === false))
$invoke404 = true;
}
}
}
}

if ($invoke404)
$wp_query->set_404();

}
add_action(‘template_redirect’, ‘wppb_set404’);

//function to decode all the extra tags
function wppb_decode_extraTag($tagName){
//filter to get current user by either username or id(default); get user by username?
$userlistingFilterArray[‘getUserByID’] = false;
$userlistingFilterArray[‘getUserByID’] = apply_filters(‘wppb_userlisting_get_user_by_id’, $userlistingFilterArray[‘getUserByID’]);

//get user ID
if (isset($_GET[‘userID’])){
$user = get_userdata($_GET[‘userID’]);
$username = $user->user_login;
}else{
if ($userlistingFilterArray[‘getUserByID’] === false){
$userID = get_query_var( ‘username’ );
$user = get_userdata($userID);
$username = $user->user_login;
}else
$username = get_query_var( ‘username’ );
}

$user = get_user_by(‘login’, $username);

if ($user->ID == null)
return ”;

if ($tagName == ‘extra_go_back_link’){
//return ‘<‘;
return $userlistingFilterArray[‘backLink’] = apply_filters(‘wppb_userlisting_go_back_link’, ‘

‘);

}elseif($tagName == ‘meta_user_name’){
$userData = get_the_author_meta( ‘user_login’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_user_name’, $userData, $user);

}elseif ($tagName == ‘meta_email’){
$userData = get_the_author_meta( ‘user_email’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_email’, $userData, $user);

}elseif ($tagName == ‘meta_first_name’){
$userData = get_the_author_meta( ‘first_name’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_first_name’, $userData, $user);

}elseif ($tagName == ‘meta_last_name’){
$userData = get_the_author_meta( ‘last_name’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_last_name’, $userData, $user);

}elseif ($tagName == ‘meta_nickname’){
$userData = get_the_author_meta( ‘nickname’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_nickname’, $userData, $user);

}elseif ($tagName == ‘meta_display_name’){
$userData = get_the_author_meta( ‘display_name’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_display_name’, $userData, $user);

}elseif ($tagName == ‘meta_website’){
$userData = get_the_author_meta( ‘user_url’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_website’, $userData, $user);

}elseif ($tagName == ‘meta_aim’){
$userData = get_the_author_meta( ‘aim’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_aim’, $userData, $user);

}elseif ($tagName == ‘meta_yim’){
$userData = get_the_author_meta( ‘yim’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_yim’, $userData, $user);

}elseif ($tagName == ‘meta_jabber’){
$userData = get_the_author_meta( ‘jabber’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_jabber’, $userData, $user);

}elseif ($tagName == ‘meta_biographical_info’){
$userData = get_the_author_meta( ‘description’, $user->ID );
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_biographical_info’, $userData, $user);

}elseif ($tagName == ‘meta_registration_date’){
$time = date(“n/j/Y”, strtotime($user->user_registered));

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_registration_date’, $time, $user);

}else{
global $wppbFetchArray;

if (count($wppbFetchArray) >= 1){
foreach($wppbFetchArray as $key => $value){
if (‘meta_’.$value[‘item_title’] == $tagName){

switch ($value[‘item_type’]) {
case “input”:{
$userData = get_user_meta($user->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_’.$value[‘item_title’], $userData, $user);
}
case “checkbox”:{
$userData = get_user_meta($user->ID, $value[‘item_metaName’], true);

if ($userData != ”){
$userDataArray = explode(‘,’, $userData);
$checkBoxValue = $value[‘item_options’];
$newValue = str_replace(‘ ‘, ‘#@space@#’, $checkBoxValue); //we need to escape the spaces in the options list, because it won’t save
$checkboxValue = explode(‘,’, $value[‘item_options’]);
$checkboxValue2 = explode(‘,’, $newValue);
$nr = count($userDataArray);

$userData = ”;

for($i=0; $i<$nr-2; $i++) $userData .= $userDataArray[$i]. ', '; $userData .= $userDataArray[$nr-2]; }else $userData = '-'; return $userData = apply_filters('wppb_userlisting_extra_meta_tag_'.$value['item_title'], $userData, $user); } case "radio":{ $userData = get_user_meta($user->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_’.$value[‘item_title’], $userData, $user);
}
case “select”:{
$userData = get_user_meta($user->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_’.$value[‘item_title’], $userData, $user);
}
case “countrySelect”:{
$userData = get_user_meta($user->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_’.$value[‘item_title’], $userData, $user);
}
case “timeZone”:{
$userData = get_user_meta($user->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_’.$value[‘item_title’], $userData, $user);
}
case “datepicker”:{
$userData = get_user_meta($user->ID, $value[‘item_metaName’], true);
if ($userData == ”)
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_’.$value[‘item_title’], $userData, $user);
}
case “textarea”:{
$userData = get_user_meta($user->ID, $value[‘item_metaName’], true);
if ($userData != ”)
$userData = nl2br($userData);
else
$userData = ‘-‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_’.$value[‘item_title’], $userData, $user);
}
case “upload”:{
$imgSource = WPPB_PLUGIN_URL . ‘/assets/images/’;
$script = WPPB_PLUGIN_URL . ‘/premium/functions/’;
$userData = get_user_meta($user->ID, $value[‘item_metaName’], true);
$fileName = str_replace ( get_bloginfo(‘home’).’/wp-content/uploads/profile_builder/attachments/userID_’.$user->ID.’_attachment_’, ”, $userData );

if (($userData == ”) || ($userData == get_bloginfo(‘url’).’/wp-content/uploads/profile_builder/attachments/’))
$retUserData = ‘‘. __(‘Current file’, ‘profilebuilder’) .’: ‘. __(‘No uploaded attachment’, ‘profilebuilder’) .’‘;
else
$retUserData = ‘‘. __(‘Current file’, ‘profilebuilder’) .’: ‘.$fileName.’‘;

return $userData = apply_filters(‘wppb_userlisting_extra_meta_tag_’.$value[‘item_title’], $retUserData, $user);
}
case “avatar”:{
$imgSource = WPPB_PLUGIN_URL . ‘/assets/images/’;
$userData = get_user_meta($user->ID, $value[‘item_metaName’], true); // to use for the link
$userData2 = get_user_meta($user->ID, ‘resized_avatar_’.$value[‘id’], true); //to use for the preview

//this checks if it only has 1 component
if (is_numeric($value[‘item_options’])){
$width = $height = $value[‘item_options’];
//this checks if the entered value has 2 components
}else{
$sentValue = explode(‘,’,$value[‘item_options’]);
$width = $sentValue[0];
$height = $sentValue[1];
}

if ($userData != ”){
if ($userData2 == ”){
wppb_resize_avatar($user->ID);
$userData2 = get_user_meta($user->ID, ‘resized_avatar_’.$value[‘id’], true); //to use for the preview

}

$imgRelativePath = get_user_meta($user->ID, ‘resized_avatar_’.$value[‘id’].’_relative_path’, true); //get relative path
//get image info
$info = getimagesize($imgRelativePath);

//this checks if it only has 1 component
if (is_numeric($item_options)){
$width = $height = $item_options;
//this checks if the entered value has 2 components
}else{
$sentValue = explode(‘,’,$item_options);
$width = $sentValue[0];
$height = $sentValue[1];
}

//call the avatar resize function if needed
if (($info[0] != $width) || ($info[1] != $height)){
wppb_resize_avatar($user->ID);
//re-fetch user-data
$userData2 = get_user_meta($user->ID, ‘resized_avatar_’.$value[‘id’], true); //to use for the preview
}

if (($userData == ”) || ($userData == get_bloginfo(‘url’).’/wp-content/uploads/profile_builder/avatars/’))
return $avatarImage = get_avatar($user->ID, $value[‘item_options’] );
else{

// display the resized image
$retUserData = ‘'. __('Avatar', 'profilebuilder') .'‘;
// display a link to the bigger image to see it clearly
return $retUserData .= ‘‘;
}

}else
return $avatarImage = get_avatar($user->ID, $width );
}
}

}elseif(‘meta_description_’.$value[‘item_title’] == $tagName){
return $value[‘item_desc’];
}
}
}
}
}

//function to parse the interWhileContent
function wppb_parse_interWhileContent($string, $object){

$stringLength = strlen($string);
$partialContent = ”;
$nCount = 0;

while ($nCount < $stringLength){ if (($string[$nCount] == '%') && ($string[$nCount+1] == '%')){ $nCount = $nCount+2; $tagName = ''; while(($string[$nCount] != '%') && ($string[$nCount+1] != '%')){ $tagName .= $string[$nCount]; $nCount++; } $tagName .= $string[$nCount]; $nCount = $nCount+3; $partialContent .= wppb_decode_metaTag($tagName, $object); }else{ $partialContent .= $string[$nCount]; $nCount++; } } return $partialContent; } //function to handle the case when a search was requested but there were no results function no_results_found_handler($content){ $retContent = ''; $formEnd = strpos( (string)$content, '

‘ );

for ($i=0; $i<$formEnd+7; $i++){ $retContent .= $content[$i]; } $userlistingFilterArray['noResultsFound'] = '

‘. __(‘No results found!’, ‘profilebuilder’) .’

‘;
$userlistingFilterArray[‘noResultsFound’] = apply_filters(‘wppb_no_results_found_message’, $userlistingFilterArray[‘noResultsFound’]);

return $retContent.$userlistingFilterArray[‘noResultsFound’];
}

//the function to extract the raw html code (and more) from the back-end
function wppb_custom_userlisting_contents($allowedRoles, $meta_key, $meta_value){
ob_start();

$customUserListingSettings = get_option(‘customUserListingSettings’,’not_found’);

if ($customUserListingSettings != ‘not_found’){

$finalContent = ”;
$username = ”;
$username = get_query_var( ‘username’ );

if (($username != ”) || (isset($_GET[‘userID’]))){
$content = $customUserListingSettings[‘singleUserlisting’];
$contentLength = strlen($content);

$i = 0;

while($i < $contentLength){ if (($content[$i] == '%') && ($content[$i+1] == '%')){ $i = $i+2; $tagName = ''; while(($content[$i] != '%') && ($content[$i+1] != '%')){ $tagName .= $content[$i]; $i++; } $tagName .= $content[$i]; $i = $i+3; $finalContent .= wppb_decode_extraTag($tagName); }else{ $finalContent .= $content[$i]; $i++; } } echo html_entity_decode($finalContent); }else{ $content = $customUserListingSettings['allUserlisting']; $interWhileContent = ''; $contentLength = strlen($content); $startWhileUsers = strpos( (string)$content, '%%extra_while_users%%' ); $endWhileUsers = strpos( (string)$content, '%%extra_end_while_users%%' ); /* if (isset($_GET['page'])){ $pageNum = $_GET['page']; $pageNum = $pageNum - 1; }else $pageNum = 0; */ $pageNum = get_query_var ('page'); if ($pageNum > 0)
$pageNum = $pageNum – 1;

// query users
$getUsersArg = ”;
$getUsersArg = apply_filters(‘wppb_userlisting_get_users_param’, $getUsersArg);

$args = array(
‘number’ => $customUserListingSettings[‘sortingNumber’],
‘offset’ => $pageNum*$customUserListingSettings[‘sortingNumber’],
‘role’ => $getUsersArg,
‘meta_key’ => $meta_key,
‘meta_value’ => $meta_value,
‘meta_compare’ => ‘LIKE’,
‘search’ => ”,
‘fields’ => ‘all_with_meta’
);
if ( isset( $_REQUEST[‘setSortingCriteria’] ) )
$args[‘orderby’] = $_REQUEST[‘setSortingCriteria’];

if ( isset( $_REQUEST[‘setSortingOrder’] ) )
$args[‘order’] = $_REQUEST[‘setSortingOrder’];

// Query the user IDs for this page
$wp_user_search = new WP_User_Query( $args );
$thisPageOnly = $wp_user_search->get_results();
$totalUsers = $wp_user_search->get_total();
// end query users

//start creating the pagination
include_once (‘pagination.class.php’);
if (($totalUsers != ‘0’) || ($totalUsers != 0)){
$pagination = new wppb_pagination;
$first = __(‘«« First’, ‘profilebuilder’);
$prev = __(‘« Prev’, ‘profilebuilder’);
$next = __(‘Next » ‘, ‘profilebuilder’);
$last = __(‘Last »»’, ‘profilebuilder’);
/*if (isset($_GET[‘page’]))
$currentPage = trim($_GET[‘page’]);
else
$currentPage = ‘1’;*/

$currentPage = get_query_var (‘page’);

if ($currentPage == 0)
$currentPage = 1;
}

//specify results per page
if (isset($_POST[‘searchFor’])){
if ((trim($_POST[‘searchFor’]) == __(‘Search Users by All Fields’, ‘profilebuilder’)) || (trim($_POST[‘searchFor’]) == ”)){
if (($totalUsers != ‘0’) || ($totalUsers != 0))
$userInfoPages = $pagination->generate($totalUsers, $customUserListingSettings[‘sortingNumber’], ”, $first, $prev, $next, $last, $currentPage);
}else{
if (($totalUsers != ‘0’) || ($totalUsers != 0))
$userInfoPages = $pagination->generate($totalUsers, $customUserListingSettings[‘sortingNumber’], trim($_POST[‘searchFor’]), $first, $prev, $next, $last, $currentPage);
}
}elseif (isset($_GET[‘searchFor’])){
if (($totalUsers != ‘0’) || ($totalUsers != 0))
$userInfoPages = $pagination->generate($totalUsers, $customUserListingSettings[‘sortingNumber’], trim($_GET[‘searchFor’]), $first, $prev, $next, $last, $currentPage);
}else{
if (($totalUsers != ‘0’) || ($totalUsers != 0))
$userInfoPages = $pagination->generate($totalUsers, $customUserListingSettings[‘sortingNumber’], ”, $first, $prev, $next, $last, $currentPage);
}

$i = 0;

while($i < $contentLength){ if ($startWhileUsers == $i){ $i = $i + 21; while ($i < $endWhileUsers){ $interWhileContent .= $content[$i]; $i++; } foreach ($thisPageOnly as $localKey => $localValue)
$finalContent .= wppb_parse_interWhileContent($interWhileContent, $localValue);

}elseif (($content[$i] == ‘%’) && ($content[$i+1] == ‘%’)){
$i = $i+2;
$tagName = ”;

while(($content[$i] != ‘%’) && ($content[$i+1] != ‘%’)){
$tagName .= $content[$i];
$i++;
}
$tagName .= $content[$i];
$i = $i+3;

$finalContent .= decode_sortTag($tagName);
}else{
$finalContent .= $content[$i];
$i++;
}
}

if (($totalUsers != ‘0’) || ($totalUsers != 0))
echo html_entity_decode($finalContent);
else{
$finalContent = no_results_found_handler($finalContent);
echo html_entity_decode($finalContent);
}

if (($totalUsers != ‘0’) || ($totalUsers != 0)){
$pageNumbers = ‘

‘.$pagination->links().’

‘;
$userlistingFilterArray[‘userlistingTablePagination’] = apply_filters(‘wppb_userlisting_userlisting_table_pagination’, $pageNumbers);
echo $userlistingFilterArray[‘userlistingTablePagination’];
}

}
}

$output = ob_get_contents();
ob_end_clean();

return $output;
}

//function to alter the default wp query
function wppb_custom_user_search_query($wp_user_query) {
global $roles;
global $wpdb;

$wppbFetchArray = get_option(‘wppb_custom_fields’);
$allowedRoles = explode(‘,’, $roles);

//filter to set search fields; search all: true – search basic fields only: false
$userlistingFilterArray[‘searchALlFields’] = apply_filters(‘wppb_userlisting_search_all_fields’, true);

//search was requested
if (isset($_REQUEST[‘searchFor’])){

//was a valid string enterd in the search form?
if ($_REQUEST[‘searchFor’] != __(‘Search Users by All Fields’, ‘profilebuilder’)){

//set the FROM condition
$wp_user_query->query_fields = “SQL_CALC_FOUND_ROWS t1.ID”;
$wp_user_query->query_from = ”
FROM $wpdb->users AS t1
LEFT OUTER JOIN $wpdb->usermeta AS t2 ON t1.ID = t2.user_id AND t2.meta_key = ‘first_name’
LEFT OUTER JOIN $wpdb->usermeta AS t3 ON t1.ID = t3.user_id AND t3.meta_key = ‘last_name’
LEFT OUTER JOIN $wpdb->usermeta AS t4 ON t1.ID = t4.user_id AND t4.meta_key = ‘nickname'”;
if ($userlistingFilterArray[‘searchALlFields’] === true){
$wp_user_query->query_from .= ”
LEFT OUTER JOIN $wpdb->usermeta AS t5 ON t1.ID = t5.user_id AND t5.meta_key = ‘description’
LEFT OUTER JOIN $wpdb->usermeta AS t6 ON t1.ID = t6.user_id AND t6.meta_key = ‘aim’
LEFT OUTER JOIN $wpdb->usermeta AS t7 ON t1.ID = t7.user_id AND t7.meta_key = ‘yim’
LEFT OUTER JOIN $wpdb->usermeta AS t8 ON t1.ID = t8.user_id AND t8.meta_key = ‘jabber’
LEFT OUTER JOIN $wpdb->usermeta AS t9 ON t1.ID = t9.user_id AND t9.meta_key = ‘”.$wpdb->prefix.”capabilities'”;

//set the FROM condition for the custom fields
$i = 9;
foreach($wppbFetchArray as $key => $value)
if ($value[‘item_type’] != ‘heading’){
$i++;
$wp_user_query->query_from .= ” “;
$wp_user_query->query_from .= “LEFT OUTER JOIN $wpdb->usermeta AS t”.$i.” ON t1.ID = t”.$i.”.user_id AND t”.$i.”.meta_key = ‘”.$value[‘item_metaName’].”‘”;
}
}

//set the WHERE condition
$wp_user_query->query_where = ”
WHERE (
t2.meta_value LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t3.meta_value LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t4.meta_value LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%'”;
if ($userlistingFilterArray[‘searchALlFields’] === true){
$wp_user_query->query_where .= ”
OR
t5.meta_value LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t6.meta_value LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t7.meta_value LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t8.meta_value LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t1.user_login LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t1.user_nicename LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t1.user_email LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t1.user_url LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t1.user_registered LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%’
OR
t1.display_name LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%'”;

//add WHERE conditions for the custom fields
$i = 9;
foreach($wppbFetchArray as $key => $value)
if ($value[‘item_type’] != ‘heading’){
$i++;
$wp_user_query->query_where .= ” “;
$wp_user_query->query_where .= “OR t”.$i.”.meta_value LIKE ‘%”.mysql_real_escape_string(trim($_REQUEST[‘searchFor’])).”%'”;
}
}

$wp_user_query->query_where .= “)”;
//limit to certain roles only
if ((count($allowedRoles) > 0) && ($allowedRoles[0] != ‘*’)){
$wp_user_query->query_where .= ” AND (“;
foreach ($allowedRoles as $thisKey => $thisValue){
$wp_user_query->query_where .= “t9.meta_value LIKE ‘%”.mysql_real_escape_string(trim($thisValue)).”%'”;
if ($thisKey < count($allowedRoles)-1) $wp_user_query->query_where .= ” OR “;
}

$wp_user_query->query_where .= “)”;
}

if ((isset($_GET[‘setSortingCriteria’])) && (isset($_GET[‘setSortingOrder’]))){
if (trim($_GET[‘setSortingCriteria’]) == ‘post_count’){
$where = get_posts_by_author_sql(‘post’);
$wp_user_query->query_from .= ” LEFT OUTER JOIN (SELECT post_author, COUNT(*) as post_count FROM $wpdb->posts $where GROUP BY post_author) p ON (t1.ID = p.post_author)”;

}elseif (trim($_GET[‘setSortingCriteria’]) == ‘firstname’)
$wp_user_query->query_orderby = “ORDER BY t2.meta_value “.strtoupper(trim($_GET[‘setSortingOrder’]));

elseif (trim($_GET[‘setSortingCriteria’]) == ‘lastname’)
$wp_user_query->query_orderby = “ORDER BY t3.meta_value “.strtoupper(trim($_GET[‘setSortingOrder’]));

elseif (trim($_GET[‘setSortingCriteria’]) == ‘bio’)
$wp_user_query->query_orderby = “ORDER BY t5.meta_value “.strtoupper(trim($_GET[‘setSortingOrder’]));

else{
$i = 9;
foreach($wppbFetchArray as $thisKey => $thisValue)
if ($thisValue[‘item_type’] != ‘heading’){
$i++;
if (trim($_GET[‘setSortingCriteria’]) == $thisValue[‘item_metaName’])
$wp_user_query->query_orderby = “ORDER BY t”.$i.”.meta_value “.strtoupper(trim($_GET[‘setSortingOrder’]));
}
}
}

return $wp_user_query;

//display only certain roles
}elseif ((count($allowedRoles) > 0) && ($allowedRoles[0] != ‘*’)){
$wp_user_query->query_fields = “SQL_CALC_FOUND_ROWS t1.ID”;
$wp_user_query->query_from = “FROM $wpdb->users AS t1 LEFT OUTER JOIN $wpdb->usermeta AS t9 ON t1.ID = t9.user_id AND t9.meta_key = ‘”.$wpdb->prefix.”capabilities'”;
$wp_user_query->query_where = “WHERE”;

foreach ($allowedRoles as $thisKey => $thisValue){
$wp_user_query->query_where .= ” “;
$wp_user_query->query_where .= “t9.meta_value LIKE ‘%”.mysql_real_escape_string(trim($thisValue)).”%'”;
if ($thisKey < count($allowedRoles)-1) $wp_user_query->query_where .= ” OR”;
}
}

return $wp_user_query;

//display only certain roles if no search was requested
}else{
if ((isset($_GET[‘setSortingCriteria’])) && (isset($_GET[‘setSortingOrder’]))){
if (trim($_GET[‘setSortingCriteria’]) == ‘firstname’){
$wp_user_query->query_fields = “SQL_CALC_FOUND_ROWS t1.ID”;
$wp_user_query->query_from = “FROM $wpdb->users AS t1 LEFT OUTER JOIN $wpdb->usermeta AS t2 ON t1.ID = t2.user_id AND t2.meta_key = ‘first_name'”;
$wp_user_query->query_orderby = “ORDER BY t2.meta_value “.strtoupper(trim($_GET[‘setSortingOrder’]));

}elseif (trim($_GET[‘setSortingCriteria’]) == ‘lastname’){
$wp_user_query->query_fields = “SQL_CALC_FOUND_ROWS t1.ID”;
$wp_user_query->query_from = “FROM $wpdb->users AS t1 LEFT OUTER JOIN $wpdb->usermeta AS t3 ON t1.ID = t3.user_id AND t3.meta_key = ‘last_name'”;
$wp_user_query->query_orderby = “ORDER BY t3.meta_value “.strtoupper(trim($_GET[‘setSortingOrder’]));

}elseif (trim($_GET[‘setSortingCriteria’]) == ‘bio’){
$wp_user_query->query_fields = “SQL_CALC_FOUND_ROWS t1.ID”;
$wp_user_query->query_from = “FROM $wpdb->users AS t1 LEFT OUTER JOIN $wpdb->usermeta AS t5 ON t1.ID = t5.user_id AND t5.meta_key = ‘description'”;
$wp_user_query->query_orderby = “ORDER BY t5.meta_value “.strtoupper(trim($_GET[‘setSortingOrder’]));

}else{
if ((trim($_GET[‘setSortingCriteria’]) != ‘user_login’) && (trim($_GET[‘setSortingCriteria’]) != ‘login’) && (trim($_GET[‘setSortingCriteria’]) != ‘user_url’) && (trim($_GET[‘setSortingCriteria’]) != ‘name’) && (trim($_GET[‘setSortingCriteria’]) != ‘registered’) && (trim($_GET[‘setSortingCriteria’]) != ‘nicename’) && (trim($_GET[‘setSortingCriteria’]) != ‘url’) && (trim($_GET[‘setSortingCriteria’]) != ‘post_count’)){
$i = 9;
foreach($wppbFetchArray as $thisKey => $thisValue)
if ($thisValue[‘item_type’] != ‘heading’){
$wp_user_query->query_fields = “SQL_CALC_FOUND_ROWS t1.ID”;
$i++;
if (trim($_GET[‘setSortingCriteria’]) == $thisValue[‘item_metaName’]){
$wp_user_query->query_from = “FROM $wpdb->users AS t1 LEFT OUTER JOIN $wpdb->usermeta AS t”.$i.” ON t1.ID = t”.$i.”.user_id AND t”.$i.”.meta_key = ‘”.$thisValue[‘item_metaName’].”‘”;
$wp_user_query->query_orderby = “ORDER BY t”.$i.”.meta_value “.strtoupper(trim($_GET[‘setSortingOrder’]));
}
}
}
}

// this if checks if the roles parameter has been set (in the case that a searching parameter has been found)
if ((count($allowedRoles) > 0) && ($allowedRoles[0] != ‘*’)){
// this if checks to see if the user didn’t request a sorting after WP default fields
if ((trim($_GET[‘setSortingCriteria’]) == ‘post_count’) || (trim($_GET[‘setSortingCriteria’]) == ‘login’) || (trim($_GET[‘setSortingCriteria’]) == ‘name’) || (trim($_GET[‘setSortingCriteria’]) == ‘registered’) || (trim($_GET[‘setSortingCriteria’]) == ‘nicename’) || (trim($_GET[‘setSortingCriteria’]) == ’email’) || (trim($_GET[‘setSortingCriteria’]) == ‘url’)){
$wp_user_query->query_from .= ” LEFT OUTER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id AND $wpdb->usermeta.meta_key = ‘”.$wpdb->prefix.”capabilities'”;

$wp_user_query->query_where .= ” AND (“;
foreach ($allowedRoles as $thisKey => $thisValue){
$wp_user_query->query_where .= “$wpdb->usermeta.meta_value LIKE ‘%”.mysql_real_escape_string(trim($thisValue)).”%'”;
if ($thisKey < count($allowedRoles)-1) $wp_user_query->query_where .= ” OR “;
}
$wp_user_query->query_where .= “)”;

}else{
//custom fields and the rest of the fields not handled by WP_USER_QUERY
$wp_user_query->query_from .= ” LEFT OUTER JOIN $wpdb->usermeta AS t9 ON t1.ID = t9.user_id AND t9.meta_key = ‘”.$wpdb->prefix.”capabilities'”;

$wp_user_query->query_where .= ” AND (“;
foreach ($allowedRoles as $thisKey => $thisValue){
$wp_user_query->query_where .= “t9.meta_value LIKE ‘%”.mysql_real_escape_string(trim($thisValue)).”%'”;
if ($thisKey < count($allowedRoles)-1) $wp_user_query->query_where .= ” OR “;
}
$wp_user_query->query_where .= “)”;
}
}

}else{
// this if checks if the roles parameter has been set (in the case that a searching parameter wasn’t found, e.g. on a fresh pageload)
if ((count($allowedRoles) > 0) && ($allowedRoles[0] != ‘*’)){
$wp_user_query->query_from .= ” LEFT OUTER JOIN $wpdb->usermeta ON $wpdb->users.ID = $wpdb->usermeta.user_id AND $wpdb->usermeta.meta_key = ‘”.$wpdb->prefix.”capabilities'”;

$wp_user_query->query_where .= ” AND (“;
foreach ($allowedRoles as $thisKey => $thisValue){
$wp_user_query->query_where .= “$wpdb->usermeta.meta_value LIKE ‘%”.mysql_real_escape_string(trim($thisValue)).”%'”;
if ($thisKey < count($allowedRoles)-1) $wp_user_query->query_where .= ” OR “;
}
$wp_user_query->query_where .= “)”;
}
}

// ADMIN APPROVAL ADDON

//this is for the front-end userlistings
if (!isset($_GET[‘user_status’])){
$wppb_generalSettings = get_option(‘wppb_general_settings’);
if($wppb_generalSettings[‘adminApproval’] == ‘yes’){
$arrayID = array();

// Get term by name ”unapproved” in user_status taxonomy.
$user_statusTaxID = get_term_by(‘name’, ‘unapproved’, ‘user_status’);
$term_taxonomy_id = $user_statusTaxID->term_taxonomy_id;

$result = mysql_query(“SELECT ID FROM $wpdb->users AS t1 LEFT OUTER JOIN $wpdb->term_relationships AS t0 ON t1.ID = t0.object_id WHERE t0.term_taxonomy_id = $term_taxonomy_id”);
if ($result != false){
while ($row = mysql_fetch_assoc($result))
array_push($arrayID, $row[‘ID’]);

$nrOfIDs=count($arrayID);
$arrayID= implode( ‘,’, $arrayID );

if ($nrOfIDs)
$wp_user_query->query_where .= ” AND $wpdb->users.ID NOT IN ($arrayID)”;
}

}
}
// END ADMIN APPROVAL

return $wp_user_query;
}
}
if( !is_admin() )
add_action( ‘pre_user_query’, ‘wppb_custom_user_search_query’ );

// Add the rewrite rule
function wppb_rrr_add_rules() {

add_rewrite_rule( ‘([^/]*)/user/([^/]+)’,’index.php?pagename=$matches[1]&username=$matches[2]’, ‘top’ );
//add_rewrite_rule( ‘([^/]*)/user//?$’,’index.php?pagename=$matches[1]’, ‘top’ );
}
add_action( ‘init’, ‘wppb_rrr_add_rules’ );

// Add the store_id var so that WP recognizes it
function wppb_rrr_add_query_var( $vars ) {
$vars[] = ‘username’;
return $vars;
}
add_filter( ‘query_vars’, ‘wppb_rrr_add_query_var’ );

// Enqueue the userlisting javascript only on the needed page
function wppb_enqueue_userlisting_script($hook){

if( $hook == ‘users_page_ProfileBuilderOptionsAndSettings’ )
wp_enqueue_script(‘userlisting_script_handlder’, WPPB_PLUGIN_URL.’/premium/assets/js/userlisting.scripts.js’, ”, PROFILE_BUILDER_VERSION);
}
add_action(‘admin_enqueue_scripts’, ‘wppb_enqueue_userlisting_script’);