vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   help with custom memberlist please (https://vborg.vbsupport.ru/showthread.php?t=260749)

AFemaleProdigy 03-21-2011 11:42 PM

help with custom memberlist please
 
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...

Code:

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

<vb:if condition="is_member_of[$post, 10]">
I just tried this too and it seems to hide all users (not show any)...

Code:

<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...

Code:

<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...

Code:

{vb:raw letterbits}
Code:

{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?

Code:

($hook = vBulletinHook::fetch_hook('memberlist_query_userscount')) ? 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?


All times are GMT. The time now is 11:36 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01070 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete