Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Custom pre-defined ( dynamic ) signatures based on usergroup/username

422422 Developer MVP
edited April 2013 in Vanilla 2.0 - 2.8

Just wondered if anyone had a suggestion for code like this.

Idea:
Our system is sso, so user name is same across the site, forum and master site.

If usergroup belong to say XYZ

Is it possible to create a php signature snippet, as this would be great for our forums.

There was an error rendering this rich post.

Tagged:
«1

Comments

  • businessdadbusinessdad Stealth contributor MVP

    With User Group do you mean Role?

  • 422422 Developer MVP

    Yes sorry. Freudian slip.

    There was an error rendering this rich post.

  • UnderDogUnderDog MVP
    edited April 2013

    @422 said:
    Just wondered if anyone had a suggestion for code like this.
    If usergroup belong to say XYZ
    Is it possible to create a php signature snippet, as this would be great for our forums.

    Oof! I think it's the same logic as the http://vanillaforums.org/addon/roletitle-plugin. Or the plugin that gives colors to different ranks? I remember a plugin from some time ago... (but can't find the link)

    There was an error rendering this rich post.

  • 422422 Developer MVP
    edited April 2013

    We are using such a plugin mate, but want to hook up specific sigs' based on role. That are auto created dynamically.

    So say user DAVE is a member on our site / forum ( remember we are using SSO ) for this example.

    We give DAVE user role , Advisor.

    If usergroup advisor, then display signature

    Then for signaures we wish to turn OFF manual signatures. And fire some php in the signature code itself, to do certain things / display that is.

    So logic is: if usergroup not equal to Advisor, display:none;

    If usergroup = advisor, echo whatever

    We follow strict user convention patterns

    There was an error rendering this rich post.

  • peregrineperegrine MVP
    edited April 2013

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • 422422 Developer MVP

    will do , back in office soon. So will have a looksy thanks

    There was an error rendering this rich post.

  • you keep saying user groups - so I am confused. are you still freudian slipping? or did you mean Roles.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • 422422 Developer MVP

    Role

    There was an error rendering this rich post.

  • this should do what you want then. I'm not quite sure what part of dynamic you mean dynamic roles , or dynamic signatures.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I think dynamic signatures based on roles.

    If Role == 'Community MVP' {$Signature = "I am an MVP!"} else {"I need to become an MVP!"}

    (should be 'case' statement in the future)

    There was an error rendering this rich post.

  • businessdadbusinessdad Stealth contributor MVP

    Suggestion: when reading @422 replies, mentally apply the following regular expression:

    preg_replace('/[usergroup|user group]/i', 'role', $What422wrote);
    
  • SrggamerSrggamer HardCore Gamer ✭✭✭

    May my role be Stalker?

  • @422

    did the plugin work for you

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • 422422 Developer MVP

    gonna test in a about an hour, I dont think it will. But will see...

    There was an error rendering this rich post.

  • 422422 Developer MVP

    Downloaded and I dont get it, what is it supposed to do.

    No additional edit info in user cp.

    Nothing in Dashboard ( aside from in options , donate )

    Dont see any way to actually use this. Perhaps you could explain.

    your readme says: "Please go to the settings page in the dashboard for this plugin." so I did and it states, no settings to be made just donate.

    Am I missing something ??

    There was an error rendering this rich post.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    what this does is give you the option of putting role based signatures, icons whatever you want after each discussion or comment. In the default.php is where you put the stuff you want. It does not have a user interface for each user. This is done for the role people can have. Even hidden roles. You just add the roles you want and what you want the signature to display.

     // here is where you can modify
             
             $member = T("Member");
             $administrator = T("Administrator");
             $moderator = T("Moderator");
             
            //  $anotherrole = T("RoleNameToAdd");
             
              $UserSig = "";
             
             
             //  if (in_array($anotherrole, $Roles)) 
             //       $UserSig = T("the another role signature");
             
               if (in_array($member, $Roles)) 
                    $UserSig = T("the members signature");
                    
                if (in_array($moderator, $Roles)) 
                  $UserSig =  T("The Mod Rules this Joint, so behave or be banished");   
              
               if (in_array($administrator, $Roles)) 
                  $UserSig = Img("http://www.vrijvlinder.com/forum/uploads/thumbnails/FileUpload/26/bb0fffc720f1e74027e573dbcc9124.png");
             
          
         // end of  modify block
    
    

    in the image below, you can see that I added my image as a signature. The post below says my member signature, which is the default. That is where you can change the stuff.

    I think you could even add the option of adding ranks to this and say new users get the newb signature and the Role Newb to correspond with the sig you give them.

    very cool plugin @peregrine !!

  • 422422 Developer MVP

    Will have another look, later ( sorry burning both ends of the candle ) this week.

    There was an error rendering this rich post.

  • peregrineperegrine MVP
    edited April 2013

    @422

    in the details section on the download page I wrote this:

    it's pretty easy to modify the plugin for additional roles, or roles not in english. just go into default.php.

    to change wording of signature look in locale of plugin


    @vrijvlinder

    Good example - but not the best way! for changing a signature for one of the 3 defaullt roles.

    V, when it comes to defintions - I can't comprehend your logic.
    When you've got a definition staring you in the face - you don't like to use it :).
    When you don't have a definition you make one up.

    the better way without modifying code -(which is what you did V) is to change the definition in the plugin locale definitions or in conf/locale.php

    e.g.

    $Definition["the administrators signature"] = 'me new admin sig';
    $Definition["the moderators signature"] = "my new moderator sig";
    $Definition["the members signature"] = ""; // no sigs for members



    V pasted the code where I put the alerting comment :)


    //here is where you can modify

    so if you looked in the default.php (from the details on the download page).

    you would see the // comments.

    then if you created "Custom roles - e.g. Advisor"
    then if Dave has an Advisor role . (the role you had given in vanilla.) and
    the only role based signature you wanted.

    you could change the code

     if (in_array($administrator, $Roles)) 
                  $UserSig = T("the administrators signature");
    

    to

     if (in_array($administrator, $Roles)) 
                $UserSig = T("the administrators signature");
    
     if (in_array("Advisor", $Roles))
    $UserSig = T("The Advisor role signature"); 
    
    
    and then in definitions.php
    
    
    
    
    $Definition["The Advisor role signature"] = '' The New Advisor Signature ";
    $Definition["the administrators signature"] = '';  // this would blank out a signature for the role
    $Definition["the moderators signature"] = "";
    $Definition["the members signature"] = "";
    
    ------
    
    if the user is a Moderator role and a  "Advisor Role"  but you prefer the Moderator role to take precedence.
    
    you would place the new advisor role  above
    
     if (in_array($moderator, $Roles)) 
                  $UserSig =  T("the moderators signature");  
    
    
      to:
    
    
    
     if (in_array("Advisor", $Roles))
         $UserSig = T("The Advisor role signature"); 
    
       if (in_array($moderator, $Roles)) 
                  $UserSig =  T("the moderators signature");   
    

    since the moderator role is below the Advisor role in the code - it takes precedence if the user is BOTH a Moderator and Advisor.


    if the user is a Moderator role and a "Advisor Role" but you prefer the Advisor role to take precedence.

    you would place the new advisor role below

     if (in_array($moderator, $Roles)) 
                  $UserSig =  T("the moderators signature");  
    
    
    
    
    to:
    
    
       if (in_array($moderator, $Roles)) 
                  $UserSig =  T("the moderators signature");   
    
    if (in_array("Advisor", $Roles))
         $UserSig = T("The Advisor role signature"); 
    
    
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Yea I realized that after I looked in the locale. doe!

    That makes things even better for sure. I guess I rushed to explain how to edit, I really only wanted to explain what it did more clearly.

    I must have taken the shortbus....this explanation should be with the plugin or tagged with the plugin so people can find it easy. Maybe paste the whole relevant section into the Readme.txt

    I like it very much indeed. It can serve to hold badges, notices , happy birthday notice so people know it's their bday. It has a million uses :)

  • peregrineperegrine MVP
    edited April 2013

    V,

    pockets could do what you want better as far as birthdays. this is for rolebased sigs.
    But i suppose you could add anything, in the same way people used to use lotus 123 as a word processor instead of a spreadsheet. Or a hammer for a screwdriver.

    But if the only plugin you are using is this one, then everything will look like a sig, just as when all you've got is a hammer, everything looks like a nail.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.