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

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -