Change the color of a specific user
Description
This tutorial will show you how to change the writting color of specific users by using Javascript.
Set up
You will have to create a new Javascript. For this, go in your administration control panel like this:
> ACP | Modules | HTML & JAVASCRIPT | Javascript codes management | Create a new Javascript
Insert this code In the topics:
- Code:
var pseudos_couleur = ["pseudo_1","pseudo_2"];
var color_texte_admin = "#D20101";
function estPseudoCouleur(pseudo){
for(i=0;i<pseudos_couleur.length;i++){
if(pseudo == pseudos_couleur[i]){
return true;
}
}
return false;
}
$(function() {
$("span.name span strong,.postprofile strong,h4.username span strong,dl.postprofile-details.postdetails span strong").each(function(){
if(estPseudoCouleur($(this).text())){
$(this).parents("tr.post").find("div.postbody div").css('color',color_texte_admin);
$(this).parents("div.inner").find("div.postbody div").css('color',color_texte_admin);
$(this).parents("div.post").find("div.post-entry div.entry-content").css('color',color_texte_admin);
$(this).parents("div.postbody").find("div.post-entry").css('color',color_texte_admin);
}
});
});
Customize the tutorial
You have to change this part to put the name of the users:
- Code:
var pseudos_couleur = ["pseudo_1","pseudo_2"];
After this, you have to change the writting color with this part:
- Code:
var color_texte_admin = "#D20101";
You can add several codes on your Javascript codes management for several users, but you can't apply two colors to a member.
Technical problems
![]() | The code will apply to the signature if you haven't apply a color to it. The tutorial was tested on PhpBB2, PhpBB3 and Invision forums and works with every browsers; If you notice that the tutorial doesn't work for a browser or for a version of forum (PhpBB2, PhpBB3, PunBB, Invision) contact an administrator and we will fill this field with your segnalation. Thanks, the staff |
![]() | For every problem or question please, contact us in the section Support for the tutorials, The staff will answer you as soon as it is possible... |
Friendly,
The team of the Forum of Codes.
![]() | Last update: 24/03/2012 - The code is now functional with Invision forums. |
Last edited by Redge on Tue Mar 27, 2012 4:05 am; edited 2 times in total