PDA

View Full Version : Widget display to certain usergroups only


Ninos
11-03-2010, 02:57 PM
I have searched but I cannot seem to find the mod I am looking for.

At the moment, if a widget is created it is displayed to every usergroup. You cannot change this. I want to be able to restrict the widget to certain usergroups (in my case: [if guest] display widget [if not] do not display widget)

Surely this is a simple thing to do? Isn't there some code I can add somewhere?? Can anyone give me advice/the correct code on how to do this?

All help greatly appreciated! Thanks!

Ninos
11-04-2010, 09:48 PM
bump

Lynne
11-04-2010, 10:00 PM
Just use your own template (enter it in the configure screen) and put a condition around it so it only shows to guests (or whoever).

Ninos
11-05-2010, 09:16 PM
Thanks for your answer Lynne!

Can you help me out with the code however?

I'd like to do the following if possible:
- Let me just briefly explain what the widget is so you understand my intentions. It is a HTML widget that displays an image and text that prompts guests to register.
- I'd like to display it ONLY to the guest usergroup
- When logged in, the content should change to a prompt (again custom text/image in html form) that prompts regular users to upgrade to a paid subscription
- If the user is already in the paid subscription usergroup the widget shouldn't display.

Is that possible? I'm thinking something like:

"if usergroup (guest_usergroup_id) display <CODE>; if usergroup (all_usergoups_except_guest) display <CODE>; if usergroup (subscribed_usergroup_id) hide"

I don't know much about php/the inner workings of vBulletin so I hope that makes sense and something similar can be achieved.

If not possible, I suppose I'd just create 2 SEPERATE widgets:
- The register prompt widget: displays only to guests
- The upgrade account prompt: displays all groups apart from the subcribed group

Thanks for your help so far :)

Lynne
11-06-2010, 12:07 AM
I don't know which method would work best. I think you'd have to see which is easier for you to do. I'd probably go for the two separate widgets each with custom templates and a condition around that template:
Template 1:
<vb:if condition="$show['guest']">stuff</vb:if>and Template 2:
<vb:if condition="$show['member'] AND !is_member_of($bbuserinfo, x)">stuff</vb:if>I would guess that would work but I've never tried something like that.

sportsfroma2
01-08-2011, 03:34 PM
Hi, sorry for the n00bish question, but on a related note- if someone wanted to make a widget appear for all except a certain usergroup, what would be the correct code?

thanks

Lynne
01-08-2011, 04:35 PM
Hi, sorry for the n00bish question, but on a related note- if someone wanted to make a widget appear for all except a certain usergroup, what would be the correct code?

thanks
vB4 Template Conditionals List (https://vborg.vbsupport.ru/showthread.php?t=231525)

charlesr
07-13-2012, 09:00 PM
Just to say I found the info in this thread useful. Cheers.
It wouldn't let me "like" the posts (too old?), so thought it worth posting to say thanks properly.