Version: 1.00, by MrEyes
Developer Last Online: May 2017
Category: End-User Options -
Version: 3.7.0 RC 3
Rating:
Released: 04-17-2008
Last Update: Never
Installs: 22
Re-useable Code Code Changes Translations
No support by the author.
User Optional Word Censorship
What this hack does
The default censorship options in VB are all or nothing, in other words it is either enabled or disabled for all users regardless of their personal preference. Without any additional SQL calls and an extremely low runtime impact (on top of the resource usage required when using the censor in the first place), this hack gives the user the option to view your forum with the AdminCP configured censor switched on if you have it enabled.
How to install
In summary the install requires:
Around 2 minutes.
1 file change.
The addition of a custom user profile field.
A basic understanding of PHP.
So this is what you need to do:
First create a custom user profile field:
Log in to your AdminCP.
Goto "User Profile Fields -> Add New User Profile Field"
In "Profile Field Type" select "Multiple-Selection Checkbox" and then click "Continue"
In "Title" enter "Enable word censor" *
In "Description" enter "If you choose to enabled this option all words on the current censor list will be replaced with * characters" *
In "Options" enter "Enable censor" *
Set "Private Field" to "Yes"
Set "Field Searchable on Members List" to "No"
Set "Show on Members List" to "No"
Set "Display Page -> Which page displays this option?" to "Options: Other"
Click "Save", this will then take you to a page that summarises all current profile fields.
On this profile fields list find the one you just added and take note of the "Name" value. Typically this will be somthing like "Field5".
* These options set the text that is displayed to the user, feel free to customise/change these to whatever you want.
All the AdminCP work is done now, so if you want logout. The next step is to make a small file edit, to check this field value when VB calls the censor code.
Take a backup of "includes\functions.php" just incase something goes horribly wrong.
Open the "includes\functions.php" file in your favourite text editor.
Find the following lines (typically these are around line 545):
Code:
if ($vbulletin->options['enablecensor'] AND !empty($vbulletin->options['censorwords']))
{
Immediately after the lines above (i.e. after the {) add the following code:
Code:
if ((isset($vbulletin->userinfo['field5'])) && ($vbulletin->userinfo['field5'] != 1))
{
return $text;
}
You should end up with something that looks like this:
Code:
if ($vbulletin->options['enablecensor'] AND !empty($vbulletin->options['censorwords']))
{
if ((isset($vbulletin->userinfo['field5'])) && ($vbulletin->userinfo['field5'] != 1))
{
return $text;
}
if (empty($censorwords))
Now this is probably the most complicated part of this simple install. Remember when you setup the profile field and you took a note of the "Name" value? Well in the text you just pasted into the function.php file you need to change this:
Code:
if ((isset($vbulletin->userinfo['field5'])) && ($vbulletin->userinfo['field5'] != 1))
To match the name of the field, so for example if your field name is "Field12", it would look like this:
Code:
if ((isset($vbulletin->userinfo['field12'])) && ($vbulletin->userinfo['field12'] != 1))
Save the file, and upload to your server.
The last, and most critically important step is:
Click Install
All done, sit back and relax
Footnotes
By default the censor will be off for all users, so they will have to change their profile in order to enabled this. I could not find a way to create a profile checkbox field that is checked by default, and describing how to run SQL scripts to set the field value is more complicated than I wanted to go with this simple hack. So if anybody knows how to do this post the details and I will update the article. In the meantime a simpler option (rather than playing with the DB) is to use "Yes" / "No" radio buttons and set the default value to Yes (or no if you prefer). If you do this you will also have to subtly change the code above from:
Code:
if ((isset($vbulletin->userinfo['field5'])) && ($vbulletin->userinfo['field5'] != "Yes"))
to:
Code:
if ((isset($vbulletin->userinfo['field5'])) && ($vbulletin->userinfo['field5'] != "Yes"))
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Dosn't work, just makes the screen go white and nothing else.
This is my code, i might of missed something obvious..
PHP Code:
if ($vbulletin->options['enablecensor'] AND !empty($vbulletin->options['censorwords']))
{
if ((isset($vbulletin->userinfo['field13'])) && ($vbulletin->userinfo['field13'] != "Yes"))
{
return $text;
}
Theres one problem, when the post is submitted, it censors the words and puts them in the database censored. So if this is turned off, they will display uncensored for all users.
OK I installed this exactly how you said and when I go to disable the censor
it says
"A required field called Enable word censor is missing or has an invalid value."
What am I doing wrong?
eta:
My code
PHP Code:
if ($vbulletin->options['enablecensor'] AND !empty($vbulletin->options['censorwords'])) { if ((isset($vbulletin->userinfo['field10'])) && ($vbulletin->userinfo['field10'] != 1)) { return $text; }
You need to go to your options, create a list of censor words and then turn it on. The user then can decide to use the censoring or not by adding or removing the checkmark.
Have you created a censor list in your options in the admin control panel?
OK I installed this exactly how you said and when I go to disable the censor
it says
"A required field called Enable word censor is missing or has an invalid value."
What am I doing wrong?
eta:
My code
PHP Code:
if ($vbulletin->options['enablecensor'] AND !empty($vbulletin->options['censorwords']))
{
if ((isset($vbulletin->userinfo['field10'])) && ($vbulletin->userinfo['field10'] != 1))
{
return $text;
}
ok did all that and Im not getting an error message anymore but it isnt working.
I added test to the list of curse words, turned it on, and it isnt working still