View Single Post
Old 2010-01-03, 11:46   Link #6
felix
sleepyhead
*Author
 
 
Join Date: Dec 2005
Location: event horizon
+1
  • "User switch for postbit." steps
    I'm going to adapt the process recommended by the vB team for the 3.x series to work for vB4. I won't mention what I changed to what since mostly its just 5 lines of code to compare if you are interested.

    Part 1: Adding user selectable option in "Forum Options" section
    1. Go to User Profile Fields > Add New User Profile Field > Single-Selection Menu
    2. Title: "Thread Postbit Position"
    3. Description: "Sets where user profile information is displayed in each post."
    4. For options enter 2 lines, one with "Left" on it and another with "Top".
    5. For Set Default select Yes, Including a First Black Option
    6. Filed required: No
    7. Private Field: Yes
    8. Field Searchable on Members List: No
    9. Show on Members List: No
    10. And lastly set Which page displays this option? to Options: Thread Viewing

    You will have obtained a new profile field, by default it is "Uncategorized" and provided this is a clean install it will have the id 5, as in referenced by "field5". If the field you've created has a different id take note of it and replace all instances of "field5" bellow with your own.

    Part 2: Creating a plugin to make use of the option.
    1. Go to Plugins & Products > Add New Plugin
    2. Leave product to vBulletin, though you could just have a holder product if you wish.
    3. Hook Location: fetch_foruminfo
    4. Set Title to "Postbit User-Selector"
    5. Plugin PHP Code
      Code:
      if ($vbulletin->userinfo['field5'] == 'Left')
      {
         $vbulletin->options['legacypostbit'] = 1;
      }
      if ($vbulletin->userinfo['field5'] == 'Top')
      {
         $vbulletin->options['legacypostbit'] = 0;
      }
    6. Save and Enable it and you're done.

Note that's vBulletin 4 code, haven't tested but doubt it will work on 3.8 or earlier. The old 3.x version of the code can be made to work by asis by enabling the compatibility aliases, that's also not recommended.

Screenshots:
. .
__________________
felix is offline   Reply With Quote