Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-23-2012, 10:16 AM
Bioman2k Bioman2k is offline
 
Join Date: Dec 2003
Location: France
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Change username color with a profile field

Hi,

I've made a World of Warcraft board for my guild.
Yesterday, I added new custom profile fields like player's name, player's class, player's server...

I would like to know if it's possible to attribute specific color to members when then correctly choose their class.

For example, if I register to my board and choose "mage", automatically, my name in every forums will be colored in #558A84.

To do that, I added the following CSS into additionnal.css file :

Code:
/* WoW Color Class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
.chaman {
	color:#0070DE;
	font-weight:bold;
}

.hunter {
	color:#ABD473;
	font-weight:bold;
}

.warlock {
	color:#9482C9;
	font-weight:bold;
}

.hunter {
	color:#ABD473;
	font-weight:bold;
}

.dk {
	color:#C41F3B;
	font-weight:bold;
}

.druid {
	color:#ff7d0a;
	font-weight:bold;
}

.warrior {
	color:#c79c69;
	font-weight:bold;
}

.mage {
	color:#69CCF0;
	font-weight:bold;
}

.monk {
	color:#558A84;
	font-weight:bold;
}

.paladin {
	color:#f58cba;
	font-weight:bold;
}

.priest {
	color:#000000;
	font-weight:bold;
}

.rogue {
	color:#fff468;
	font-weight:bold;
}
Any idea to do that ?
Thank you all in advance.
Reply With Quote
  #2  
Old 09-26-2012, 12:23 PM
Bioman2k Bioman2k is offline
 
Join Date: Dec 2003
Location: France
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No Idea ?
Reply With Quote
  #3  
Old 09-28-2012, 12:29 PM
Bioman2k Bioman2k is offline
 
Join Date: Dec 2003
Location: France
Posts: 12
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, I'd added usergroups like mage, DK, paladin and put a color CSS on them.

My question :
Is it possible to make a scheduled task (as CRON) which scan everyday for all members their profile field value and assign them onto the good usergroup.

I hope i was understandable.

Have a nice day.
Reply With Quote
  #4  
Old 09-28-2012, 12:54 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To answer your original question, you can make a plugin using hook fetch_musername that sets $user['musername'] (the formatted username) to whatever you want. But one issue is that you aren't guaranteed to have the user's custom fields available so you would have to do a database query to get any that you wanted to check. And since this is called to format posts, it could be called more than once for each user, so you'd probably want some kind of caching of fields to cut down on the number of queries.

To answer the above quesiton, you could do that. Hook cron_script_cleanup_hourly is called in the hourly cleanup script, so you could use that, or you could write your own scheduled task php script. You might want to look at includes/cron/promotion.php since it does something similar.

Another way to do what you're trying to do might be to find a hook that's called when the custom fields are edited, so you can detect a change in the field and reset the usergroups. One of the hooks in class_dm_user.php might work, like maybe userdata_presave (you'd have go to that file and look at the code around that hook to figure out exactly what to do).
Reply With Quote
Благодарность от:
CAG CheechDogg
Reply


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 11:09 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03655 seconds
  • Memory Usage 2,192KB
  • 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
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (1)post_thanks_box_bit
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete