Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2009, 08:52 PM
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Location: Murrells Inlet, SC
Posts: 216
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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!
Reply With Quote
  #2  
Old 08-29-2009, 10:51 AM
RLShare RLShare is offline
 
Join Date: Jun 2008
Posts: 499
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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'.
Reply With Quote
  #3  
Old 09-02-2009, 08:12 PM
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Location: Murrells Inlet, SC
Posts: 216
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm sorry, but I don't exactly know how to write that. I'm still learning php and conditional statements. I usually try to figure it out myself, but I am a little stumped. Can you write it out for me?
Reply With Quote
  #4  
Old 09-03-2009, 06:05 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And your page currently contains? (Please post your code.)
Reply With Quote
  #5  
Old 09-10-2009, 02:07 PM
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Location: Murrells Inlet, SC
Posts: 216
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>Technician Roster - $vboptions[bbtitle]</title>
$headinclude
<LINK HREF="../AMtechVB.css" TYPE="text/css" REL="stylesheet"/>
</head>
<body style="color:#FFCC33">
$header
 
<div id="content">
      <div >
 
   <div id="primary">
    <h1>$vbphrase[technician_roster]</h1>  
 
                <form action="profile.php?do=deleteusergroups&amp;usergroupid=$usergroupid" method="post">
<input type="hidden" name="do" value="deleteusergroups" />
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="usergroupid" value="$usergroupid" />
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center" style="border-bottom-width:0px">
<tr>
 <td class="tcat" width="100%">
  Alabama
 
 </td>
 
</tr>
</table>
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr align="center">
 <td class="thead" align="$stylevar[left]" nowrap="nowrap"><a href="$sorturl<if condition="!$show['sorturlnoargs']">&amp;</if>order=ASC&amp;sort=username&amp;pp=$perpage$usergrouplink">$vbphrase[username]</a> $sortarrow[username]</td>
 <if condition="$show['usergroup']"><td class="thead"><input name="allbox" type="checkbox" value="Check All" title="$vbphrase[check_uncheck_all]" onClick="checkall(this.form);" /></td></if>
</tr>
$memberlistbits
<tr>
 <td class="tfoot" colspan="15" align="$stylevar[right]">
 
 </td>
</tr>
</table>
</form>
 
 
 
 
 
 
   </div><!-- #primary -->
   <div id="secondary" class="sidebar">
       <ul id="subMenu">
    <li><a href="#">Benefits</a></li>
    <li><a href="#">Boards of Directors</a></li>
    <li class="active"><a href="#">Certification</a></li>
    <li><a href="#">Charter</a></li>
    <li><a href="#">Code of Ethics</a></li>
    <li><a href="#">Contact Amtech</a></li>
    <li><a href="#">Join Now</a></li>
    <li><a href="#">Officers</a></li>
       </ul>
   </div><!-- #secondary -->
      </div><!-- #wrap -->
  </div><!-- #content -->
 
     <div id="siteInfo">
      <ul>
   <li class="first"><a href="#">About AMTECH</a></li>
   <li><a href="#">Why Join?</a></li>
   <li><a href="#">Community Forums</a></li>
   <li><a href="#">Member Resources</a></li>
   <li><a href="#">Training &amp; Services</a></li>
   <li><a href="#">Contact AMTECH</a></li>
      </ul>
      <h6>AM-TECH Assaociation of Marine Technicians &copy;2009 All rights reserved </h6>
  </div><!-- #siteInfo -->
 
</body>
</html>
--------------- Added 10 Sep 2009 at 11:09 ---------------

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:
<if condition="$userinfo[field7] == OH"><a href="member.php?$session[sessionurl]u=$userinfo[userid]">$userinfo[musername]</a></if> 
Reply With Quote
  #6  
Old 09-14-2009, 04:22 PM
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Location: Murrells Inlet, SC
Posts: 216
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Help? Please?
Reply With Quote
  #7  
Old 09-14-2009, 04:33 PM
binaryg's Avatar
binaryg binaryg is offline
 
Join Date: Mar 2009
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

in your template, you can match the member to their usergroup with

Code:
<if condition="is_member_of($bbuserinfo, X, Y, Z)">
Reply With Quote
  #8  
Old 09-14-2009, 04:49 PM
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Location: Murrells Inlet, SC
Posts: 216
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 09-14-2009, 05:40 PM
binaryg's Avatar
binaryg binaryg is offline
 
Join Date: Mar 2009
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What about
Code:
<if condition="is_member_of($bbuserinfo, X, Y, Z)">
<if condition="$profilefield[value] == "somevalue">
do stuff
</if>
</if>
Reply With Quote
  #10  
Old 09-14-2009, 06:54 PM
AFemaleProdigy's Avatar
AFemaleProdigy AFemaleProdigy is offline
 
Join Date: Mar 2006
Location: Murrells Inlet, SC
Posts: 216
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)">
<if condition="$profilefield[field7] == "OH">
do stuff
</if>
</if>
and also this...

HTML Code:
<if condition="is_member_of($bbuserinfo, 2, 6)">
<if condition="$userinfo[field7] == "OH">
do stuff
</if>
</if>
I get this parse error only when the second IF statement is included...
----
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)">
<if condition="$profilefield[field7] == 'OH'">
test
</if>
</if>
--------------- Added [DATE]1252959502[/DATE] at [TIME]1252959502[/TIME] ---------------

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)">
<if condition="$bbuserinfo[field7] == 'OH'">
$bbuserinfo[username]
</if>
</if>
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:33 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
  • Page Generation 0.04620 seconds
  • Memory Usage 2,281KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (5)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete