2020-09-22, 01:16 PM
Hello,
I'm using Page Manager to make separate memberlists for member groups. I want to add a custom profile field next to the usernames.
Here's the code I'm using for group id 18:
As profile fields are stored in a different table, I can't fetch the custom fields with the code I have above. My PHP knowledge is limited. I tried to fetch fid4 inside the while loop, as I needed to use the user_id variable I defined above.
Here's what I got:
This is not working, though. No errors, no outputs, when I add $user_opt2 in the page.
What am I doing wrong?
I'm using Page Manager to make separate memberlists for member groups. I want to add a custom profile field next to the usernames.
Here's the code I'm using for group id 18:
<?php
global $headerinclude, $header, $theme, $footer, $db, $xtpf, $userfields;
$altbg = alt_trow();
$userlist = '';
$query = $db->simple_select("users", "*", "usergroup IN ('18')", array("order_by" => 'username', "order_dir" => 'ASC'));
while($users = $db->fetch_array($query))
{
$username = build_profile_link(format_name(htmlspecialchars_uni($users['username']), $users['usergroup'], $users['displaygroup']), $users['uid']);
$userlist .= '<tr><td class="'.$altbg.'">'.$username.', '.$users["usertitle"].'</td></tr>';
$altbg = alt_trow();
}
$template='<html>
<head>
<title>'.$pages['name'].'</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="'.$theme['borderwidth'].'" cellpadding="'.$theme['tablespace'].'" class="tborder">
<thead>
<tr>
<td class="thead">
<strong>'.$pages['name'].'</strong>
</td>
</tr>
</thead>
<tbody>
{$userlist}
</tbody>
</table>
<br />
{$footer}
</body>
</html>';
$template=str_replace("\'", "'", addslashes($template));
add_breadcrumb($pages['name']);
eval("\$page=\"".$template."\";");
output_page($page);
?>
As profile fields are stored in a different table, I can't fetch the custom fields with the code I have above. My PHP knowledge is limited. I tried to fetch fid4 inside the while loop, as I needed to use the user_id variable I defined above.
Here's what I got:
$userid = $users['uid'];
$useroptq = $db->simple_select("userfields", "*", "ufid='.$userid.'");
$user_opt = $db->fetch_array($useroptq);
$user_opt2 = $user_opt["fid4"];
This is not working, though. No errors, no outputs, when I add $user_opt2 in the page.
What am I doing wrong?