MyBB Community Forums

Full Version: Variable to "call" in global templates?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I'm looking for which variable I can use to "call" to certain custom profile fields (fidx does not work in this instance) in the Global templates. 

I have a plugin that can display all of the members in a certain usergroup, and I want to be able to add some custom profile field info for each user in that group on the page that displays them all. 

Some of the variables that the template already uses are {$user['avatar']}, {$user['username']}, etc., if it helps. I've tried {$user['fidx']} but to no avail.
Tried $mybb->user['fidx'] ?
Works! Thank you very much!
(2015-07-02, 02:53 PM)Ad Bakker Wrote: [ -> ]Tried $mybb->user['fidx'] ?

Actually, this solution is unfortunately not working. While it does display a value for that custom profile field, it displays the SAME value for every member (it displays the value for whoever updated that custom field last).

Any idea if there is another call variable that will actually gather the information from ONLY the member listed?
I understand it now. The problem is that the $user array elements are probably only filled from the users database table. The userfields are in a different table, and to get these also in the $user array, the SQL Query in your plugin should be changed.
Can you give a link to the plugin you use?
Absolutely. The plugin is called "View Groups" http://mods.mybb.com/view/view-groups
^ exactly which version of MyBB you are using ?
this topic is in MyBB 1.8 support section and the plugin you are using belongs to MyBB 1.6
(2015-07-11, 01:46 PM).m. Wrote: [ -> ]^ exactly which version of MyBB you are using ?
this topic is in MyBB 1.8 support section and the plugin you are using belongs to MyBB 1.6

Sorry, this is actually the one I'm using: http://community.mybb.com/mods.php?action=view&pid=10
I grabbed the link to the wrong one.
Replace line 292 of  viewgroups.php:
$query = $db->simple_select("users", "*",$search_sql, array('limit' => "{$start}, {$per_page}"));
by:
$query = $db->query("SELECT u.*, f.*
		FROM ".TABLE_PREFIX."users u
		LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid = u.uid)
		WHERE {$search_sql}
		LIMIT {$start}, {$perpage}
");

I believe I did'n make a syntax error, when I do (curly brackets are tricky sometimes)  .m. will see Big Grin .
You need to redefine $search_sql to use u.usergroup not usergroup because of using aliasing on the mybb_users table. You'll also need to look at $additional_sql and change it to u.additionalgroups. Finally, in $total_rows you need to change
($db->simple_select("users", "COUNT(uid) as users", $search_sql), "users");
to
($db->simple_select("users u", "COUNT(u.uid) as users", $search_sql), "users");
Pages: 1 2 3