WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] how to use add_settings_error() for nested options array (2 posts)

  1. datdesignguy
    Member
    Posted 2 years ago #

    Hi All,

    I'm building a theme with custom-options using Otto's fantastic tutorial on the WordPress settings API as a basis for my custom theme options.

    I have registered a new setting: iblaunchy_options and all of my theme's settings are stored inside of this option:

    register_setting( 'iblaunchy_options', 'iblaunchy_options', 'iblaunchy_options_validate' );

    I'm currently working on the validation function, and would like to be able to display errors on the options page if one of the options in my validation function fails to pass.

    I'm not sure how to do this. I read up on the codex for add_settings_error and settings_errors but am still unsure how to proceed.

    Has anyone come across a good explanation of how to use these settings api functions to display errors back to an options page built using the method in Otto's tutorial?

    I'm just not sure how to show errors for these settings because they are nested within the iblaunchy_options setting.

    Any ideas?

    Thanks,

    Greg J

  2. datdesignguy
    Member
    Posted 2 years ago #

    I figured out how to achieve this. After a few searches, a few failed attempts, all that was missing was a call in my options page template to settings_errors and the manner in which I addressed my settings themselves in the call to add_settings_error.

    This post on WP stackexchange was skooper helpful in solving my problem.

    Also this post on WP Engineer inspired the example I've pasted below (the only difference between my example and theirs, is I show you where to insert the call to show_errors... theirs is far more thorough)

    Here's a code example from start to finish: http://pastebin.com/K4kJ0DNG

Topic Closed

This topic has been closed to new replies.

About this Topic