![]() |
User defined PHP function in custom block
I've searched everywhere and I can't find a definitive answer to my question. I'm having trouble getting a user defined php function to execute inside of a custom block.
Code:
$my_output = 'Bad'; Also, do these same issues arise if I define the php code as a plugin? I haven't been able to get it to work that way either and I figured it would be better to define the code in the block anyways. |
Quote:
|
You need to make sure $my_output is a global variable. You need a global statement inside the good() function, and you also may need one at the beginning of the plugin code, depending on the hook being used. So try something like:
Code:
global $my_output; ETA: or you could use a reference parameter or return a value from good(), but probably your actual code is different than the example you posted, so maybe that won't work. |
Thank you for the global suggestion I think that would solve part of the problem, but I don't think that was entirely the issue because I've tried returning straight from the function and it never executed.
I did solve my problem though, I just got rid of the function because it seems like too much of a hassle to try to work around. Was easier to just execute the code where needed. To answer the first question, in a forum block. It's not a large chunk of code, but I needed to do a call to the database and some manipulating. The function was just for output formatting so I just scrapped it. |
All times are GMT. The time now is 02:26 PM. |
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:
|