Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I know by watching the akismet plugin source how to show a custom message on the plugins page, but I want my message to appear only once after my plugin is activated.

How could i do this?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The easiest way would be to check for an stub get_option something like

$run_once = get_option('run_once');

if (!$run_once){
    //show your custom message here
    // then update the option so this message won't show again
    update_option('run_once',true);
}

hope this helps

share|improve this answer
1  
Thanks, that looks logical, should I use the hook "admin_notices" to "echo" my message or is there another better hook to do it? Because if I use register_activation_hook() it will show an error on activation. –  user3007 Feb 8 '11 at 0:51
    
admin_notices is the correct hook to use –  Wipqozn Aug 22 '11 at 19:49
    
You have an error in your code. get_option will return FALSE if the option does not exist, therefore isset will return true in your example. –  Wipqozn Aug 22 '11 at 19:55
    
@Wipqozn: 100% agreed. –  Bainternet Aug 23 '11 at 11:15
3  
This is an option but it is a bit dirty IMO. Let's say you have the plugin activated for a year. Now this value is checked in the database for the whole year, but it was needed only once. That's a whole bunch of spilled db look-ups and checks for something so simple. –  Saif Bechan Nov 30 '11 at 15:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.