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.
public function database_name_check($input){
    //debug
    add_settings_error('notice', 'lol', 'lol');
    if($this->wpdb->get_var($this->wpdb->prepare('SHOW DATABASES LIKE %s', $input)) == $input)
        return $input;
    else{
        add_settings_error('notice', 'lol', 'lol');
        return FALSE;
    }
}

I can not understand why the error does not exceed, any suggestions?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Take a look at the add_settings_error prototype.

add_settings_error( $setting, $code, $message, $type );

The first argument is your settings name/key -- or if your setting is on another page (eg general) it should be the page key. The second is whatever you'd like to add to the ID attribute, then error/updated message, and finally type. It doesn't work because you're using it incorrectly.

So you probably want...

<?php
add_settings_error(
    'your_setting_key', // whatever you registered in `register_setting
    'a_code_here', // doesn't really mater
    __('This is the message itself', 'wpse'),
    'error', // error or notice works to make things pretty
);

You also need to tell WordPress to display your settings errors. If it's on a custom page, you'll need to include settings_errors in the callback.

settings_errors('your_setting_key');
share|improve this answer
    
pastebin.com/3XsexNcg here is full example, but still not working with or without die(). –  user1692333 Jan 2 '13 at 21:07
    
See my edit, make sure you include settings_errors in your admin page callback. –  chrisguitarguy Jan 2 '13 at 21:15
    
yes, already found this solution, but thanks. –  user1692333 Jan 2 '13 at 21:21

Your Answer

 
discard

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.