HomeHome  
  • WelcomeWelcome  
  • Events  
  • PublicationsPublications  
  • FAQFAQ  
  • SearchSearch  
  • MemberlistMemberlist  
  • UsergroupsUsergroups  
  • RegisterRegister  
  • Log inLog in  
  • You are not connected. Please login or register


    Change the color of a specific user

    avatar
    • Veteran staff member

        Reputation : 8
        Registered on : 2012-03-24
        Posts : 30
      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"];
      It has to be the exactly same names as on the forum or the code will not work. Your free to add additional names on this code.

      After this, you have to change the writting color with this part:
      Code:
      var color_texte_admin = "#D20101";
      Except of using hexadecimal colors, you can use colors such as red, white, blue but they have to be in english. ;)

      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

      avatar
      • Veteran staff member

          Reputation : 14
          Registered on : 2012-02-25
          Posts : 98
        But for that you can also use the CSS

        avatar
        • Veteran staff member

            Reputation : 8
            Registered on : 2012-03-24
            Posts : 30
          @MartinoPio wrote:But for that you can also use the CSS

          You can change by default the color of writting with the CSS. ;) This trick changes all the time the color, no need of any code.

          avatar
          • **


              Reputation : 2
              Registered on : 2012-03-24
              Posts : 20
            Thanks sisi

            avatar
            • Administrator

                Reputation : 315
                Registered on : 2012-02-22
                Posts : 2317
                School of codes courses: coming soon
              Thanks Redge :birra:



              Niko wants you in the team Guest

              Community manager and Administrator at Forumattivo.com

              avatar
              • Veteran staff member

                  Reputation : 8
                  Registered on : 2012-03-24
                  Posts : 30
                Hi,

                You're welcome everybody. ;)

                avatar
                • ***


                    Reputation : 1
                    Registered on : 2014-12-11
                    Posts : 49
                    Love Fmcodes
                  Can you show us the change?


                  YOUR BANNER HERE
                  728x90
                  DMCA.com Protection Status
                  Free forum | © PunBB | Free forum support | Contact | Report an abuse | Forumotion.com