Home WordPress Settings API add_settings_error() issue
Reply: 1

WordPress Settings API add_settings_error() issue

Vadim Cherepenichev
1#
Vadim Cherepenichev Published in 2018-02-14 11:31:19Z

To create plugin custom settings page using wp Settings API wordpress suggests us to use something like this:

<form method="post" action="options.php">
    <?php settings_fields( 'group_name' );
    do_settings_sections( 'group_name' );
    submit_button( 'Save Changes' ); ?>
</form>

When I add the settings page errors using the add_settings_error() all the things work great. But I have noticed that if action="" I'll get 2 copies of the same custom error.

get_settings_errors() returns an array with 0 and 2 keys (1 is missed). In 0 and 2 lays the same custom errors (duplicates).

I am sure it is not an issue of my code due to with action="options.php" I have not this issue.

It seems I do not know something. Can somebody explain me?

Zaheer Abbas
2#
Zaheer Abbas Reply to 2018-02-17 12:13:31Z

After the opening form tag, add this function

  register_settings( 'myoption-group' );

where myoption-group is the same name used in the register_setting function. You don't have register setting diclear.

refrence link : https://codex.wordpress.org/Creating_Options_Pages

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299726 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO