![]() |
Passing PHP variables between products
I have a php product hooked to global_start which adds in a banner add at the top of every page, and also does some basic geo-location and provides a country code. Obviously this requires a database access.
I want to be able to pass the same country code on to another product that shows another banner on the threads page (below the first post). This has to be hooked to the postbit_display_start to get it to work I think. The question is - how do I store a global variable accessible in the second script please? I can't find anything about this through searching. |
When you set a variable in the first plugin, it may or may not be in the global scope. It will be in whatever scope the hook function is called from. To do what you want to do, simply save the variable in the super global array.
$GLOBALS['testvar'] = 'testval'; It will be available for the rest of the script (unless someone unsets it along the way :)) |
That worked perfectly, thank you. You have saved me a good few hours of trawling and desperate trial and error coding. Much appreciated.
|
No problem, just realise that it's a hack and not "clean", since the variable is not encased in a class/object with access limitations etc, it's "out in the open" and can be modified/deleted by any other plugin you might install.
|
so make sure you sanatize that variable before hand. you could also add it to the $vbulletin variable which is usually available to all parts of vBulletin.
|
All times are GMT. The time now is 01:10 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|