Cannot get any settings page values

Support MB Settings Page Cannot get any settings page values

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #42039
    steve@1upmediasolutions.com[email protected]
    Participant

    I'm using Bricks and have a few settings page and a couple hundred custom the the entire website. I've been using the theme code to get values from various pages to accomplish various tasks, but no matter what I do I cannot get the theme code to return any values at all from a settings page.

    Here's 2 examples of nothing returned from settings page options:

    function get_top_bar_cta() {
    $group = rwmb_meta( 'header_alpha_settings', [ 'object_type' => 'setting' ], 'easy_settings' );
    return $group[ 'top_bar_call_to_action' ] ?? '';
    }

    - Nothing

    function get_header_type_setting() {
    	$group = rwmb_meta( 'header_alpha_settings', [ 'object_type' => 'setting' ], 'easy_settings' );
    	return $group[ 'top_bar_call_to_action' ] ?? '';
    }

    - Nothing

    Here's a couple page options:

    function get_mini_cta_value() {
    	$mini_cta = rwmb_the_value( 'mini_cta' );
    	return $mini_cta;
    }

    - No problem, returns "
    Take your landscaping to the next level with our professional and creative design solutions."

    function get_hero_status() {
    $hero_sw_status = rwmb_meta( 'quick_settings_options' )[ 'hero_section_on_off' ] ?? 0;
    return $hero_sw_status;
    }
    - No problem, returns 1 (switch position)

    Here's the settings page code:

    <?php
    add_filter( 'mb_settings_pages', 'ru360_easy_settings' );
    
    function ru360_easy_settings( $settings_pages ) {
    	$settings_pages[] = [
            'menu_title'    => __( 'RU360 Easy Settings', 'rampup360.com' ),
            'id'            => 'easy-settings',
            'position'      => 2,
            'class'         => 'ru360SettingsPage',
            'style'         => 'no-boxes',
            'columns'       => 1,
            'tabs'          => [
                'configure_company_data'     => 'Configure Company Data',
                'configure_website_settings' => 'Configure Website Settings',
                'configure_sidebar_settings' => 'Configure Sidebar Settings',
                'configure_module_settings'  => 'Configure Module Settings',
                'configure_crm_integration'  => 'Configure CRM Integration',
                'backup_and_restore'         => 'Backup & Restore',
            ],
            'tab_style'     => 'left',
            'submit_button' => __( 'SAVE SETTINGS', 'rampup360.com' ),
            'message'       => __( 'Your Settings Have Been Saved!', 'rampup360.com' ),
            'option_name'   => 'easy_settings',
            'icon_url'      => 'dashicons-admin-generic',
        ];
    
    	return $settings_pages;
    }
    #42066
    PeterPeter
    Moderator

    Hello,

    Can you please share the generated PHP code from the field group that is assigned to the setting page? You can also use the WordPress function get_option() to get a setting page value.

    Your two functions get_mini_cta_value() and get_hero_status() look getting the field value associated with a post, not a setting page. Please read more in the documentation https://docs.metabox.io/extensions/mb-settings-page/#settings-fields

    #42096
    Rob van TuinRob van Tuin
    Participant

    Hi,
    I had the same problem and I found out that rwmb_meta() does not work for options in the admin area but you can use the get_option()

    So instead of:
    rwmb_meta( 'header_alpha_settings', [ 'object_type' => 'setting' ], 'easy_settings' )
    use
    get_option('easy_settings')['header_alpha_settings']

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