Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Aug 2002
Posts: 27
User
User
Offline
Joined: Aug 2002
Posts: 27
Is there a hack to limit new users ability to send and receive PM’s? A probation period sort of. I thought of putting all new users in a specific group but don’t see a way to control the PM feature by group.

I’m sure it’s probably around here somewhere but I couldn’t produce the results I was looking for with a search.

Thanks

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Rather than just writing the hack.... I'll answer this as a How do I....

This same technique can be applied to a variety of scrips.

Near the top of each script, there is an authenticate function, which gets the user name, number, permissions etc.....

In sendprivate.php, look for this:

Code
<br />// -----------------<br />// Get the user info<br />   $userob = new user;<br />   $user = $userob -> authenticate("U_TextCols,U_TextRows,U_Preview");  <br />   $Username =  $user['U_Username'];<br />



First we need to get this users groups, so we can add the database field to the list, like this:
Code
<br />   $user = $userob -> authenticate("U_TextCols,U_TextRows,U_Preview,U_Groups");  <br />


Then after that bit of code, we can give it a shorter variable name if you want, like this:
Code
<br />  $UserGroups = $user['U_Groups'];<br />


Then, after that authenticate function, add a check to see if they are part of a usergroup that isn't allowed to use PMs. If they are, then we use the "not_right" function to send them a generic error message.

Code
<br />			 if (preg_match("/-5-/",$UserGroup))  { // adjust this group number if needed	<br />             $html = new html;<br />             $html -> not_right('You are not allowed to do this.',$Cat);<br />   }<br />


Hope that helps a bit.

Joined: Aug 2002
Posts: 27
User
User
Offline
Joined: Aug 2002
Posts: 27
Thank You for the lesson and help. You answer is very clear and I'll get into it later tonight.

Joined: Aug 2002
Posts: 27
User
User
Offline
Joined: Aug 2002
Posts: 27
Well here is what I did

Found the authenticate function in sendprivate.php

This

// Get the user info
$userob = new user;
$user = $userob -> authenticate("U_TextCols,U_TextRows,U_Preview,");
$Username = $user['U_Username'];


changed to this
// Get the user info
$userob = new user;
$user = $userob -> authenticate("U_TextCols,U_TextRows,U_Preview,U_Groups");
$Username = $user['U_Username'];
$UserGroups = $user['U_Groups'];
if (preg_match("/-7-/",$UserGroup)) {
$html = new html;
$html -> not_right('You are currently not allowed to use this feature.',$Cat); }

As you proabily know it did not redirect to a not_right html. I have played with it untill I got errors and more play just seemed to move the problem. I double checked my user group number but the error seems to follow this line if (preg_match("/-7-/",$UserGroup)) {

Another leasson please.
Thanks

Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
$UserGroup should be $UserGroups

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Thanks Eagle Eye. Typo in my haste. Sorry.

Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
You're welcome, Four Eyes.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
LOL -

I'd trade the 4 eyes for 2 that saw things as good as yours do.

My problem is I do 9000 things at a time..... and get scattered.

Joined: Aug 2002
Posts: 27
User
User
Offline
Joined: Aug 2002
Posts: 27
Thanks for the answer. I thought I had changed that at one point but obviously not.

The above code changes work like a new John Deer on a sunny day but does not prevent reply to PM's. If I wanted to prevent that I would edit the sendmessage.php authentication function correct? Need to make sure I am really understanding my lessons.

Thanks everyone for you patience.


Joined: Aug 2002
Posts: 27
User
User
Offline
Joined: Aug 2002
Posts: 27
I wrote this as a result of our conversation here.

This little hack will prevent sending of private messages on your forums by user groups. It’s simple to install and can be be applied in various files by modifying the ubbT authinication script. In this example it is for sending PM’s .

All credit should be given to ubbdev.com and it’s members. Special thanks to JoshPet and Dave_L also to the owner and staff of ubbdev.com who so graciously provides the medium for all to learn.

Open your sendprivate.php file
Find this code

//--------------------------------------------------------------------------------------------------------
// Get the user info
$userob = new user;
$user = $userob -> authenticate("U_TextCols,U_TextRows,U_Preview,");
$Username = $user['U_Username'];


changed it to this
//-------------------------------------------------------------------------------------------------------
// Get the user info
$userob = new user;
$user = $userob -> authenticate("U_TextCols,U_TextRows,U_Preview,U_Groups");
$Username = $user['U_Username'];
$UserGroups = $user['U_Groups'];
if (preg_match("/-7-/",$UserGroups)) { //Edit the number 7 to match your user group.
$html = new html;
$html -> not_right('You are currently not allowed to use this feature.',$Cat); }
//You can edit the 'You are currently not allowed to use this feature.' Message to something else if you like.



Additional Steps to find out user groups number.
Go to the admin control panel of your forums. Click on sql commands under databse management.
In the window frame type this command

SELECT G_Id
FROM w3t_Groups
WHERE G_Name = 'groupnamehere'



Simple, quick, and functional hack for your threads management needs. Have Fun

If you find any bugs let me know.

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Good job. Looks like this little "starter" lesson has been useful to you, and probably to others. It's always easier to comprehend once you do it and figure it out for yourself.
I know I didn't really have a clue (although I had applied many hacks) until I rolled up my sleeves and gave it a whirl.

Good to practice all you want on a test board. If you are testing on a live board, backup your files before you modify.

You can restrict replies to a PM in this file: mess_handler.php

Here's a tip if you are looking to restrict a certain feature. Go and try that feature, and look at the URL to what script it's using. For example, when I hit "reply" to a PM, I noticed mess_handler.php in the URL. Then you know what file to modify.

Hope that helps more. Your hack looks real good.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Here's another "tip" as we have talked about building multi-language support into our hacks.... as multi-language support is a very powerful feature of threads.

Instead of hard coding the error message like this:

$html -> not_right('You are currently not allowed to use this feature.',$Cat); }


You can use a language string, like this:

$html -> not_right($ubbt_lang['NOT_ALLOWED'],$Cat); }


Then in the language files (for each language you use).... example /languages/english, look for the file with the same name as the script (like sendprivate.php).

Add a string in like this:

$ubbt_lang['NOT_ALLOWED'] = "You are currently not allowed to use this feature.";


If it's a string that's used in several scripts, you could also put it into the generic.php language file.

That' how you build in language support.



Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)