MyBB Hacks

Full Version: Contents Based On Usergroup
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Requirement: XThreads

This is a basic usage of XThreads.
Maybe this is useless for you. But I have this in one of "my" real forum to give a different contents for a different usergroup. I use this most in my Announcement Area and in my Main Area. This is one of the core and the most important feature in that forum.
Yeah, each forum has a different needs, right? Biggrin
In this example application, I've modified it a bit to make it more general. So, maybe we can use this for other purposes.

Basically, we will try to use a single thread that has a different message / contents for a different usergroup. And, we have a general message that viewable for all usergroup.

This is a simple example for it.

Custom Thread Fields Setting:
AdminCP -> Configuration -> Custom Thread Fields:
    Multiline Textbox for Messages:
    Yeah, we use multiline textbox custom thread fields only. Basically, we need to set the Permission of each our multiline textbox. So, each message filled in each textarea only viewable by a specified usergroup.

    Please remember that this is for example only. We need to modify it as our needs. We will use the custom thread fields below for displaying a specific messages for Guest Usergroup.
    • Title: Message For Guest
    • Key: guest_msg
    • Applicable Forums: 'select in whichever forums we will apply this message'
    • Input Field Type: Multiline Textbox
    • Editable by / Required Field?: Administrator
      Modify it as our needs.
    • Display Parsing: Use MyBB Parser (MyCode)
    • MyBB Parser Options: Check All, except the HTML, especially if we give the permission to use this fields to other usergroup beside Admin.
    • Display Format:

      HTML Code
      <br /><br />
      <div class="pm_alert">{VALUE}</div>

    • Viewable by Usergroups: Guest, Administrator.
      Modify it as our needs.
    • Unviewable Value:

      Code:
      &nbsp;

      Variable in template for displaying this field is: {$GLOBALS['threadfields']['guest_msg']}.

    We only need to repeat the step above. Use a different key.

Now, we need to put the variable in our template. In this example, we will put the messages in first post only. We can display some message in every post in that thread if we want.

  1. Create postbit_first and/or postbit_first_classic template.
  2. Copy and paste the entire code of our
    • postbit to postbit_first template
    • postbit_classic to postbit_first_classic template.
  3. Find {$post['message']} in those news template
  4. Add our variable at the end or at the beginning of the variable above. In this example, we need to put {$GLOBALS['threadfields']['guest_msg']} variable.


Now, we can set a specific message for a specific usergroup. And the message viewable by that usergroup only. Use the default textarea for contents that viewable for all usergroups.

Example screenshot:
In this example, I've created a specific message for Guest only, Registered only, and Awaiting Activation only.

Guest Views (can view general messages and message for Guest Usergroup only):
[attachment=371]

Registered Views (can view general messages and message for Registered Usergroup only):
[attachment=372]

Awaiting Activation Views (can view general messages and message for Awaiting Activation Usergroup only):
[attachment=370]

All Message (Administrator Views, can view all message):
[attachment=367]
Very nice!  This could be used as described or maybe even for some type of guest advertising...the possibilities are endless!
Nice Wink
someone requested this at mybb, right? Wink

good try rateu
Good try? Thats what we call damning with faint praise Smile

I think its great. Just gotta think of an application for it now....hmmm

/lee ponders
Pretty good one. Going to use it on my forum.
Holy s** man,how many brains you have xD ?
Nice share,thanks Smile
Thanks Biggrin
Excellent...One Problem is .....It not applicable on old threads as when i try to full edit old thread , there is no box for this guest message.
is any way to put this message in old thread?
thank you.
This affects both new and old threads.  Check that you've specified the right forums.
Pages: 1 2
Reference URL's