Custom plugin settings: clicking "save changes" does not display success message

admin2025-06-06  6

I don't entirely understanding how to save my plugin's settings properly. When I click on the "Save Changes" button it saves data but it does not show any successful like message. Do I need to add an extra function or something else?

My form look like this:

function bdthemes_core_settings_page() { ?>
    <div class="wrap">
        <h1>BdThemes Settings</h1>
        <form method="post" action="options.php">
            <?php
                settings_fields("section");
                do_settings_sections("plugin-options");      
                submit_button(); 
            ?>          
        </form>
    </div>
<?php 
}

I don't entirely understanding how to save my plugin's settings properly. When I click on the "Save Changes" button it saves data but it does not show any successful like message. Do I need to add an extra function or something else?

My form look like this:

function bdthemes_core_settings_page() { ?>
    <div class="wrap">
        <h1>BdThemes Settings</h1>
        <form method="post" action="options.php">
            <?php
                settings_fields("section");
                do_settings_sections("plugin-options");      
                submit_button(); 
            ?>          
        </form>
    </div>
<?php 
}
Share Improve this question edited Aug 24, 2016 at 18:55 Selim Rana asked Aug 24, 2016 at 18:43 Selim RanaSelim Rana 331 silver badge7 bronze badges 2
  • Normally, using the Settings API as you have will cause a default "Settings Saved" message. The problem would be somewhere else in your mark-up, though you could also try writing an explicit custom message via the admin_notices hook. – CK MacLeod Commented Aug 24, 2016 at 23:36
  • @CKMacLeod If one creates a sub menu and posts to options.php from there, it skips the message. – Talha Imam Commented Feb 15, 2021 at 22:54
Add a comment  | 

1 Answer 1

Reset to default 6

I had the same issue as you did, but I found how to fix it in this tutorial:

https://digwp/2016/05/wordpress-admin-notices/

Basically, I had my settings page outside of the Settings menu, so I had to explicitly add settings_errors() to my options page and they started working. :)

Hope that helps.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749184642a317070.html

最新回复(0)