![]() |
Load members of certain usergroup only?
I am creating some custom pages that will display members of certain usergroups rather then all members of the forum. So I have a usergroup called "technicians" and a custom field "state" (aka "field7"). On one page I want to load only the members from the group "technicians" that live in a certain state (example:MN).
I have my custom page created already. It is displaying ALL members right now. Can someone tell me how to list only members from the "technician" usergroup that live in the state I specify? I am guessing I could use some sort of conditional statement? Like IF user is in this group "x" and field7=MN then display userdata? Thanks! |
In your SQL query, join the 'userfield' table on the condition 'userfield.userid = user.userid' and then add a WHERE clause to the statement such as 'userfield.fieldxx = whatever'.
|
I'm sorry, but I don't exactly know how to write that. I'm still learning php and conditional statements. :o I usually try to figure it out myself, but I am a little stumped. Can you write it out for me?
|
And your page currently contains? (Please post your code.)
|
Sorry it took me so long to write back. Here is what I have so far. I just imported a bunch of users that don't have their state entered yet so just know this page does correctly display the state. Still a work in progress.
http://amtech.abovemls.com/community...ian-roster.php Here is the code for my custom template... HTML Code:
$stylevar[htmldoctype] Do you need the code for the php page code too because this site keeps telling me it's too many characters? --------------- Added [DATE]1252606073[/DATE] at [TIME]1252606073[/TIME] --------------- Can anyone just show me what the code would be for... if a user's $userinfo[field7] (custom profile field) equals "X" (variable) then display those user's usernames? I have tried to write this tons of ways and can't figure it out. I have no training in this stuff. This is what I came up with after scouring the web and guessing and finally gave up on... PHP Code:
|
Help? Please?
|
in your template, you can match the member to their usergroup with
Code:
<if condition="is_member_of($bbuserinfo, X, Y, Z)"> |
That doesn't include the custom field variable I need. I need to call by IF (custom profile field = "x"), then display usernames.
This is basicly a secondary custom member page, but I need to group individuals by state which is listed in their custom profile field (field7). I can't just use a sort arrow for the full list either. I have to break them up into groups by state of residence. |
What about
Code:
<if condition="is_member_of($bbuserinfo, X, Y, Z)"> |
I seem to be having a problem with that. I keep getting a parse error when I try to save the template with the second IF statement in it. The first one for the usergroup is ok, but when I add the one for the profile field it kills it. Maybe I am not changing the values correctly? This is what I have tried so far...
HTML Code:
<if condition="is_member_of($bbuserinfo, 2, 6)"> HTML Code:
<if condition="is_member_of($bbuserinfo, 2, 6)"> ---- The following error occurred when attempting to evaluate this template: Parse error: syntax error, unexpected T_DO in /var/www/vhosts/am-tech.org/httpdocs/community/includes/adminfunctions_template.php(3939) : eval()'d code on line 45 This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish. --------------- Added 14 Sep 2009 at 16:00 --------------- I also just tried this because I think a quote was missing or something. It eliminated the parse error, but did not output the test text. HTML Code:
<if condition="is_member_of($bbuserinfo, 2, 6)"> Ok, so I messed around some more and came up with this code, but it's only showing MY username to me if my state matches the field7 value. It's not listing all members with that value which is what I need. It should be a list of all members with that field7 value. HTML Code:
<if condition="is_member_of($bbuserinfo, 2, 6)"> |
for that you are going to need to loop through the values for each member and use that code. Though, it would probably be a bit more simple just to use a php file and select all the members from the database that meet your criteria. You might be able to get away with that if you were able to copy some code from the memberlist templates, essentially creating your own, and then use your custom information to sort the users but I think you would probably need to enable that particular field to be indexed in the memberlist. I wouldn't know which is the easiest route. I haven't played with member data very much.
ohh, and it looks like your parse error is the result of the first " in "OH". It closes out the tag |
I did make my custom page based off of the memberlist.php but I don't know what to add in there and then what to put in my template to make this work.
--------------- Added [DATE]1252966903[/DATE] at [TIME]1252966903[/TIME] --------------- What would be the fastest way for me to get this working? :) |
PHP Code:
|
All times are GMT. The time now is 04:35 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|