WordPress.org

Ready to get started?Download WordPress

Forums

sanitize_callback and add_settings_error() problem (2 posts)

  1. vidhill
    Member
    Posted 4 years ago #

    I am trying out using the Settings API in conjunction with the new add_settings_error function..

    I have an issue, I want to use the same sanitize_callback function for verifing the input of two settings..
    However, it seems that the only variables I can access from within the sanitize_callback function is the $input value...

    From searching about it seems that the $input variable was an array in WP 2.7 (and so other variables were accessible) but it just seems to be the string imputed into the form in version 3.0 RC

    (see this tutorial for WP2.7 http://ottopress.com/2009/wordpress-settings-api-tutorial/#highlighter_958949 )

    Maybe it's just not possible to re-use the same validation function.. but if all I have is a series of text inputs in my options, it'd be cleaner to be able to use one function than having to write the same function three times (with different variables)

  2. Juergen Schulze
    Member
    Posted 3 years ago #

    just call
    add_settings_error('options', 'xxxx', 'my error message');
    inside the sanitizecallback function which you created

Topic Closed

This topic has been closed to new replies.

About this Topic