PDA

View Full Version : can't get a function or require_once code to run on hook with ajax edit


BirdOPrey5
03-04-2012, 07:23 PM
OK so I'm stumped... :eek:

I have code I want to run on postbit_display_complete.

If I declare the function in the plugin or put the function in an external php file and use "require_once" it runs and works fine when i load the thread.

However if I do an ajax / quick-edit to the post and re-save it the code does not run. I assume the function isn't being declared or the file isn't being included.

However if I don't use a function and just put the code directly in the postbit_display_hook then the code runs just fine after saving a quick-edit.

It's like quick-edit runs only the postbit_display_complete hook when saving but it won't get external files or declare a function.

I tried putting the require_once code on ajax_complete hook and several edit_complete hooks with no luck.

Anyone understand what I'm saying and have any ideas? :confused:

BirdOPrey5
03-04-2012, 07:50 PM
The console in Chrome isn't showing any error... I'm thinking there's just some trick I'm missing...

BirdOPrey5
03-04-2012, 09:29 PM
EUREKA....

Actually require_once works just fine for my needs, and had I been testing this on any other hook I probably would have been OK...

My problem was my code had an if condition to only execute if THIS_SCRIPT == 'showthread' and during an edit, even a quick edit, the script becomes 'editpost' - so once I made it work on showthread or editpost it began working as I expected.

:)