MyBB Community Forums

Full Version: User.php signature preg_match?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How can I match the content of the signature from user.php

I have added this:

$signature = &$this->data['signature'];
		
		if(preg_match("/apple/", $signature, $match))
        {
			$this->set_error("ERROR - Signature can not contain words like: <strong>$match[0]</strong>.");
			return false;
        }

To function update_user but it's just not working any ideas?
I think you should have your regex be /apple/is instead. That is the first thing you should do.
I will but could you tell me please what value should I use for signature? For website is:

$website = &$this->data['website'];



$regex = '/apple|hello/';
$signature = &$this->data['signature'];   
        if(preg_match($regex, $signature, $match))
        {
            $this->set_error("ERROR - Signature can not contain words like: <strong>$match[0]</strong>.");
            return false;
        }
EDIT: oh, I see you want to add error, so you need to edit validate_user() function instead, if you want to do it inside that file. Signature is $user['signature'] there (it's called variable not value).
Thanks buddy listen do you know what Regular Expression will help me to match the word that is written in caps and small caps.

Like apple: Apple, APPLE and so on.
That's what the i modifier is for in your regex. That is part of why I suggested you have your regex end with /is.
Thanks couldn't make it work with $regex so I did this:

if(preg_match("/somewords/i", $mybb->input['signature'], $match))


D666 I think signature gets updated in the usercp.php and not in the user.php.
http://community.mybb.com/thread-154683-...pid1079446 Please, read carefully. We are all here to help but when 10 threads out of the last 10 in this forum are yours, maybe there's something you could at least search on Google instead of asking the same things on and on.

It's clear that you haven't such advanced coding skills, so why don't you begin reverse-engineering some existing plugins and/or look to MyBB's source code? That would help both you and us. I have started without knowing even what a programming language was, but I learned analyzing the source code of many plugins and the core itself helped a lot.

Also, if you are going to ask a question, please try to formulate your questions with the highest number of details possible so that we can answer you directly, without asking you things you could give us in one post rather than in five. Thank you.
Signatures get updated in inc/datahandlers/user.php. It is in the function update_user. I believe the hook you want is datahandler_user_update. This is just before the data on a user gets updated.
Thanks I am gonna take a break for a month or so cause I made many moderators really mad with all these questions.

Thanks a lot for all your support.
Pages: 1 2