The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Trying to disable color tags for some users
My members have requested the ability to disable color tags just as they can disable images. I created a profile field for this and have been trying to determine the correct hook and code to make this work. The closest I've gotten is:
Code:
if ($vbulletin->userinfo['field5'] == "Yes") { global $vbphrase, $db; $post_text = $db->query_first("SELECT pagetext FROM " . TABLE_PREFIX . "post WHERE postid = $post[postid] ORDER BY dateline ASC"); $post_color['pagetext'] = preg_replace('#\[color=sienna\](.*?)\[/color\]#si', '\1', $post_text[pagetext]); $post_color['pagetext'] = preg_replace('#\[color=black\](.*?)\[/color\]#si', '\1', $post_color[pagetext]); $post['message'] = nl2br($post_color['pagetext']); } I'm looking for a way to just remove the tags without unparsing everything else, and possibly a more efficient way of removing colors (than one at a time). |
#2
|
|||
|
|||
You could do this: create a new style and then in a plugin using hook bbcode_fetch_tags:
Code:
global $style; if ($style['styleid'] == X) $tag_list['option']['color']['html'] = '%1$s'; where the X is the new style id. I think this works because posts are cached by style. If you used a profile field instead I don't think it would work because of post caching. Obviously this isn't a good solution if you already have a number of styles that a user can choose. I'm not sure where you are putting the code in your example, maybe there's another way to do it (like maybe you could replace all <span color="xxx">whatever</span> in the post text). |
#3
|
|||
|
|||
Sorry forgot to mention this is in a plugin at the postbit_display_complete hook.
A new style is not a viable option. |
#4
|
|||
|
|||
OK, how about this:
Code:
if ($vbulletin->userinfo['field5'] == "Yes") $post['message'] = preg_replace('#<font color=".*?">(.*?)</font>#si', '\1', $post['message']); |
#5
|
|||
|
|||
Hey that worked great! Thanks!
|
#6
|
|||
|
|||
Thinking about it more, it's probably not going to work in all situations since the SIZE and FONT bbcodes also end up as <font> tags, so something like:
This is red and big still red would probably end up with "still red" being size 5 instead of normal. |
#7
|
|||
|
|||
Quote:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|