The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How do I only display a custom bbcode to logged in members?
I want to create a bbcode that only displays its contents to registered members, similar to the way the code bbcode works on vbulletin.com/org
For example, this would be my bbcode: [registered]Only registered members can view whatever I type here[/registered] This is what I figured out so far: 1. I found this post, which describes most of what is required to accomplish this: https://vborg.vbsupport.ru/showpost....17&postcount=3 2. And I know this is the code to only display something to a logged in member: <if condition="$bbuserinfo[userid]">$value</if> Can someone help me put 1 and 2 together correctly? I am not sure how to create the function properly that I would need. Any help is appreciated. |
#2
|
|||
|
|||
I think it would be:
PHP Code:
I think the string you return for unregistered members can contain whatever HTML you want, if you don't want just a text string. |
#3
|
|||
|
|||
kh99, I really appreciate the quick reply. That works like a charm. Post cache lifespan must be set to 0 for this to work, otherwise vbulletin caches the post contents and it isn't displayed correctly depending on the members login status.
Thank you for the tip, it looked simple for you, but I could barely call myself a hack so I didn't see the code in my head until you said it. This is the code I used in the plugin, in case it may help anyone else: Code:
$custom_bbcode = 'registered'; $this->tag_list['no_option'][$custom_bbcode] = array (); $this->tag_list['no_option'][$custom_bbcode]['callback'] = 'handle_external'; $this->tag_list['no_option'][$custom_bbcode]['external_callback'] = 'handle_my_custom_bbcode'; if (!function_exists ('hide_message_for_registered_users')) { function handle_my_custom_bbcode (&$theobj, &$value, &$option) { if ($theobj->registry->userinfo['userid']) return $value; else return "Unregistered members will see this"; } } |
#4
|
|||
|
|||
To check user groups you would use something like:
Code:
if (is_member_of($theobj->registry->userinfo, 1, 2, 3)) { // is a member of one of those groups } else { // is not a member of any of those groups } ETA: I had a mistake in that code, it should have been just "userinfo", not userinfo['userid']. BTW, $bbuserinfo is used in templates (not usually plugin code like this) and is equivalent to $vbulletin->userinfo. Also $theobj->registry is equivalent in this case to the global $vbulletin. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|