PDA

View Full Version : Show code in theme based on profile option?


Bomyne
10-21-2011, 01:15 AM
I'm trying to make something on my siite disabled based on a profile option? I hard coded the item into the theme.

Also, is there a way to do this via which usergroup they are in?

kh99
10-22-2011, 12:16 AM
I'm not sure what you mean by "hardcoded". If you're using templates, you should be able to put the code for the stuff you want disabled in an "if" tag, like:

<vb:if condition="$bbuserinfo[fieldX] == 'something'">
// code for feature
</vb:if>


or to do it by usergroup

<vb:if condition="!is_member_of($bbuserinfo, X)">
// code for feature
</vb:if>


Of course you need to change the X's and 'something' to the appropriate values.

Bomyne
10-24-2011, 05:15 AM
Thanks. It works perfectly.

On a variation on the second code you gave, is there a way to add that to the postbit template to show a special image or title if the user is in this usergroup?

kh99
10-24-2011, 10:31 AM
... is there a way to add that to the postbit template to show a special image or title if the user is in this usergroup?


Yes, just edit the postbit or postbit_legacy template and add something like:

<vb:if condition="is_member_of($bbuserinfo, X)">
// code for image
</vb:if>


By the way, you can include more than one usergroup if you want, by listing the ids, like:

<vb:if condition="is_member_of($bbuserinfo, 5, 6, 7)">
...

Bomyne
10-25-2011, 01:35 AM
Yes, just edit the postbit or postbit_legacy template and add something like:

<vb:if condition="is_member_of($bbuserinfo, X)">
// code for image
</vb:if>


By the way, you can include more than one usergroup if you want, by listing the ids, like:

<vb:if condition="is_member_of($bbuserinfo, 5, 6, 7)">
...

Does that work based on the viewer or the poster?

Basically what i've done is set up a supporter system. Those that donate have the ads disabled (Which is thanks to the second code block in the first post) now i want to add a badge to that users posts to aknowdge they are a supporter. The subscription system adds them to group 12.

kh99
10-25-2011, 01:56 AM
Oh right, that would be the viewer. I should have realized if you wanted it in the postbit you probably wanted the poster. In that case just replace $bbuserinfo with $post.

<vb:if condition="is_member_of($post, X)">
// code for image
</vb:if>

Bomyne
10-25-2011, 03:49 AM
Thanks! Works great.