Custom Fields
Re-Envisioned
Support MB Settings Page Disabling submit button in option page

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 6 months, 2 weeks ago.

  • Creator
    Topic
  • #10900
    Resolved
    Bezzo
    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

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #10923

    Anh 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:

    View post on imgur.com

    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 1 replies (of 1 total)

You must be logged in to reply to this topic.