Disabling submit button in option page

Support MB Settings Page Disabling submit button in option pageResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10900
    BezzoBezzo
    Participant

    Hello,

    Is there any possibility to disable submit option page? I want to create sub-option page in which there are only some information displayed from database and that submit button might be confusing 🙂

    Thanks

    #10923
    Anh TranAnh Tran
    Keymaster

    Hi Bezzo,

    You can easily hide the submit button with CSS.

    This code below lets you enqueue a CSS file for the settings page:

    add_action( 'admin_enqueue_scripts', function() {
        $screen = get_current_screen();
        if ( 'your-screen-id' == $screen->id ) {
            wp_enqueue_style( 'your-file', 'http://url-to-your.css' );
        }
    } );

    To get the screen ID of the settings page, you can use the Inspector plugin. The screen ID is shown in the "Help" tab, like this:

    https://i.imgur.com/UAIRkbc.png

    In your CSS file, you can simply enter this:

    .wrap .submit { display: none; }

    If the process above is complicated, you can use a "quick and dirty" tip below:

    When you register a meta box for the settings page, add a custom_html field like this:

    $meta_boxes[] = [
        // Other fields
        [
            'type' => 'custom_html',
            'std' => '<style>.wrap .submit { display: none; }</style>',
        ]
    ];

    It will output the <style> to the page and hide the submit button.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.