PDA

View Full Version : help with custom memberlist please


AFemaleProdigy
03-21-2011, 11:42 PM
I am creating custom memberlist pages and could use some help. I was familiar with the old vB code prior to the publishing suite, but things are different now.

I want to create a custom member list that will show members from a specific usergroup ID only. Then I want to specify which custom profile fields will be displayed (different from the default memberlist display).

So, I need to know the code to call users of usergroup ID "x" and load custom profile fields by specific ID "x,y,z".

I don't need all of the code for the memberlist template. Just the bits that I need to add or edit to make the content more specific.

Thanks for the help! :D

Lynne
03-21-2011, 11:51 PM
All of that should be the same as when you used vB3 - the php didn't change, it's the template calls and template syntax that changed. is_member_of is still the function to use to find if a user is a member of a usergroup and profile fields are still called by $variable['fieldx'] just like before.

AFemaleProdigy
03-22-2011, 02:23 AM
Thanks Lynn!

I got the custom field part down ok. But am having an issue displaying members of a specific usergroup. I have tried the following, but I get an error in admin cp...

<if condition="is_member_of($post, 10)">

<vb:if condition="is_member_of[$post, 10]">

I just tried this too and it seems to hide all users (not show any)...

<vb:if condition="is_member_of($bbuserinfo, 10)">

I am wondering if I am using the correct type of conditional statement? Just to clarify...

I am not trying to show items TO a specific usergroup. I am trying to show a memberlist OF members FROM a specific usergroup. Just wanted to say that in case there was any confusion.

Lynne
03-22-2011, 03:22 AM
Look in the template - what is the variable being used for the users? It's isn't $post (that is in the postbit templates) and it isn't $bbuserinfo (that is you, the viewer), but it will be another variable ($userinfo? I can't remember) and that is the one you want to use.

AFemaleProdigy
03-22-2011, 03:36 AM
Woohoo!! Ok so I finally got a bit farther. This works...

<vb:if condition="in_array($userinfo[usergroupid],array(10))">


However, it isn't applying that filter to the pagination function. So it's showing the same number of pages as the default memberlist (so too many pages), but has stripped out all other usergroups. How can I apply this so the pagination shows correctly?

So, the usergroupid filter I am trying to apply is not applying to this and I am not sure how best to apply that...

{vb:raw letterbits}

{vb:raw pagenav}

Lynne
03-22-2011, 04:21 PM
Look at the query that defines the pagination and modify it for your own needs.

AFemaleProdigy
03-23-2011, 01:20 AM
Any suggestions how to get the memberlist to display these users correctly? It is only showing the users from the usergroup I specified, but the page numbers and layout look like it's still counting the other members from the other groups as well.

I don't know if you would want to look at it or not as it's an adult oriented site with some nudity.

Lynne
03-23-2011, 02:59 AM
It's in your code somewhere - not anything I would see on your site. In the 'real' memberslist.php file, there is a query just to get the userscount which is then used for pagination. If your page is modeled after that page, then it's that query that you need to modify.

AFemaleProdigy
03-23-2011, 03:21 AM
I'm guessing that would be this bit of code? Any suggestions as to how I might modify it?

($hook = vBulletinHook::fetch_hook('memberlist_query_usersc ount')) ? eval($hook) : false;
$userscount = $db->query_first_slave("
SELECT COUNT(*) AS users
FROM " . TABLE_PREFIX . "user AS user
" . ($include_userfield_join ? "LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield USING (userid)" : '') . "
$hook_query_joins
WHERE $condition
AND (user.usergroupid IN ($ids)" . (defined('MEMBERLIST_INCLUDE_SECONDARY') ? (" OR FIND_IN_SET(" . implode(', user.membergroupids) OR FIND_IN_SET(', $idarray) . ", user.membergroupids)") : '') . ")
$hook_query_where
");
$totalusers = $userscount['users'];
if (!$totalusers)
{
eval(standard_error(fetch_error('searchnoresults', $displayCommon)));
}


PS... thanks so much for all your help by the way! I really appreciate it. I'm still learning PHP. I'm actually going back to college the 28th to learn PHP more in depth. :)

Lynne
03-23-2011, 03:28 AM
You will want to modify the line regarding the where users are in usergroup $ids (etc). Didn't you do the same thing in the main query which has the exact same part in the where statement?

AFemaleProdigy
03-24-2011, 01:38 AM
Hmmm... okay... I have been trying to figure this out, but just can't get it right. ugh.

EDIT:

So I figured out how to get the correct total user count and page numbers. Made one small change here (added "10" for the usergroup ID)...

$userscount = $db->query_first_slave("
SELECT COUNT(*) AS users
FROM " . TABLE_PREFIX . "user AS user
" . ($include_userfield_join ? "LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield USING (userid)" : '') . "
$hook_query_joins
WHERE $condition
AND (user.usergroupid IN (10)" . (defined('MEMBERLIST_INCLUDE_SECONDARY') ? (" OR FIND_IN_SET(" . implode(', user.membergroupids) OR FIND_IN_SET(', $idarray) . ", user.membergroupids)") : '') . ")
$hook_query_where
");

But, I think my initial idea to display usrs from a specific usergroup won't work. It does strip all other usergroups out, but it's messing up the listings. I'm trying to find another way. Any suggestions.

--------------- Added 1300938771 at 1300938771 ---------------

My oh my... I actually figured it out on my own just now!! :D Took me forever. A lot of trial and error, but I got it... with your help of course Lynn.

Managed to solve all of my issues! :cool:

Lynne
03-24-2011, 03:15 AM
Glad you figured it out. :)