MyBB Hacks

Full Version: Check if user is on showthread.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am making a plug-in and I would like to know how to check if the user is reading a thread.

PHP Code:
if(user_reading_thread == "true")

Something like that.

The easiest way is by checking the user location, something like:

PHP Code:
if(THIS_SCRIPT == 'showthread.php')

This is what I have been using but it won't work.

PHP Code:
function redirectthiss()
{
	
	global $mybb;

	if($_SERVER['SCRIPT_NAME'] == "showthread.php")
	{ 
		
		
			redirect(
				htmlentities("index.php"),
				htmlentities("1"),
				htmlentities("2")
			);

		
	}
	
}


I tryed with "*" and != too but it refuses to redirect.

I don't know where you want to put your code.
If you do it in your plugin, just hook to showthread_start. Something like this:

PHP Code:
$plugins->add_hook('showthread_start','myred');
function myred(){
	redirect('index.php','You are redirected to index','Redirecting');
}

(12-15-2015 02:04 AM)RateU Wrote: [ -> ]I don't know where you want to put your code.
If you do it in your plugin, just hook to showthread_start. Something like this:

PHP Code:
$plugins->add_hook('showthread_start','myred');
function myred(){
	redirect('index.php','You are redirected to index','Redirecting');
}

I see, the hook was the problem all the time Cry
Is there somewhere a list with all hooks?
I think you can find it in MyBB Docs.
But personally, I prefer to find it inside the script directly, so I know whatever variables exists, which hooks I can use for my purpose and etc.
I see, thank you!
Reference URL's