php - Global variables vanish in WordPress plugin -


i'm writing wordpress plugin. want display custom message after post saved. message depend on outcome of function called when post saved.

here's code:

add_action('save_post', 'my_save_post_function'); function my_save_post_function() {   global $msg;   $msg = "foo bar";   ... }  add_filter('post_updated_messages', 'my_post_updated_messages_function'); function my_post_updated_messages_function($messages) {   global $msg;   $messages["post"][1] = $msg; // !! $msg undefined !!   ... } 

why $msg undefined?

is there way can result out of save_post action? i've tried sorts of tricks. $_post data seems have been blown away time admin messages shown.

have tried session ? think problem fixed .

take @ :

http://www.php.net/manual/en/function.session-start.php


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

php - Dynamic url re-writing using htaccess -

java - Multi-Label Document Classification -