Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am developing a plugin, but during the activation phrase I am constantly facing bugs. However there is no easy way to display error messages, since echoing stuff would result in 'unexpacted output' error. I tried the admin_message hook but it doesn't work. How can I alert the user if some stage of the activation has failed with reason?

share|improve this question

3 Answers 3

up vote 6 down vote accepted

For testing purposes you can use the log system (php_error.log):

error_log('Plugin activated', 0);

// Check for DB table existance
    error_log('Database not present', 0);
        error_log('Database was created.', 0);
    } else {
        error_log('Error creating the CE Labels Plugin db tables!', 0);

} else {
    error_log('Database OK', 0);

To output error to the user without the "Headers already sent" error, you can use the php function trigger_error:

trigger_error('PLUGIN OK',E_USER_ERROR);

With Wordpress must always be E_USER_ERROR or it won't display the message.

I know the error_log works perfectly since I'm using it, but the trigger_error displays to must information. Try it and see for your self :)

share|improve this answer
Do you know where I can find further documentation on the error_log function? I'm having difficulty figuring out how to make it work. –  Nathan Arthur Mar 28 '14 at 13:33
For those who may come after: –  Nathan Arthur Mar 28 '14 at 13:50


register_activation_hook( __FILE__, 'my_activation_func' ); function my_activation_func() {
    file_put_contents(__DIR__.'/my_loggg.txt', ob_get_contents());

insert this code in plugin, and after error, view "my_loggg.txt" inside your plugin folder.

share|improve this answer

1) Please remove extra spacing in the inner pages or plugin pages.

2) remove the inline styling in the pages or plugin pages.

its worked for me everytime. i have used many times same method. when the problem error in the plugin page or Wordpress page.


Hitesh Nagpal

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.