• Resolved J M

    (@hiphopinenglish)


    Hi.

    I’m trying to get an individual meta field to display if an installation is multisite enabled using the function is_multisite().

    It doesn’t seem to be working for some reason, and my field is showing regardless. Here is the code:

    $cmb->add_field( array(
                'name' => __( 'Global Welcome Message', 'cm_lang' ),
                'desc' => __( 'This will act as the default Welcome Message (displayed on each site\'s homepage). This can be overridden by adding a Welcome Message on an individual site\'s Site Options.', 'cm_lang' ),
                'id'   => 'global_welcome_message',
                'type' => 'wysiwyg',
                'show_on_cb' => cmb_is_multisite()
            ) );

    And the callback function:

    function cmb_is_multisite() {
        if ( is_multisite() ) {
            return true;
        }
    }

    I wrote the callback function since using plain is_multisite() didn’t work.

    Thanks

    https://www.ads-software.com/plugins/cmb2/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Justin Sternberg

    (@jtsternberg)

    show_on_cb' takes a callback value (like add_action), so should be 'cmb_is_multisite'. Actually, you should just make it 'is_multisite'.

    Thread Starter J M

    (@hiphopinenglish)

    Thanks. Obviously needed a bit more sleep or at least a closer look at the docs…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘is_multisite() via 'show_on_cb'’ is closed to new replies.