MyBB Community Forums

Full Version: How to get the orange MyBB set_error box to pop up?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am trying to get the orange set_error box to pop up if a condition is met, but I get this error:

"PHP. Fatal error: Using $this when not in object context"

I am using:

        $this->is_validated = false;
        $this->set_error("myerrormessage");
        return false;

Does anyone know how to make it work?
Could you please show us the rest of your PHP code?
You should be using the object name. $this is a pseudo variable that is only available within an object.
(2015-01-13, 02:14 AM)dragonexpert Wrote: [ -> ]You should be using the object name.  $this is a pseudo variable that is only available within an object.

Could you explain this a bit more?

I'm trying to do this for usercp.php.

Let's say someone in a certain group wants to edit their profile, but I've blocked that groups ability to do so, how can I make the set_error orange box to appear for usercp.php?

Here is a similar thread: http://community.mybb.com/thread-38507.html

But I need it to work for usercp.php.
You can either use the error_no_permission function after you checked if they have permission or use error("Your message here").
(2015-01-13, 04:12 PM)dragonexpert Wrote: [ -> ]You can either use the error_no_permission function after you checked if they have permission or use error("Your message here").

Those 2 options are viable, but it requires the user to hit the back button, whereas the orange box appears on the page they were on.

Is there absolutely no way of making the orange set_error box to appear on usercp.php?