Could Not Get Field Value

Support MB Settings Page Could Not Get Field ValueResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33470
    vary@ifoundries.com[email protected]
    Participant

    Hi, I have a simple settings page with the following setup:

    
    add_filter( 'mb_settings_pages', 'limit_settings_code' );
    
    function limit_settings_code( $settings_pages ) {
        $settings_pages[] = [
            'menu_title'  => __( 'Limit Settings', 'bbcm' ),
            'option_name' => 'Limit Settings',
            'position'    => 25,
            'style'       => 'no-boxes',
            'columns'     => 1,
            'icon_url'    => 'dashicons-welcome-widgets-menus',
        ];
    
    return $settings_pages;
    
    }
    
    add_filter( 'rwmb_meta_boxes', 'credit_limit_code' );
    
    function credit_limit_code( $meta_boxes ) {
        $prefix = '';
    
    $meta_boxes[] = [
        'title'          => __( 'Credit Limit', 'bbcm' ),
        'id'             => 'credit_limit',
        'settings_pages' => ['limit_settings'],
        'fields'         => [
            [
                'name'     => __( 'Credit Limit Amount', 'bbcm' ),
                'id'       => $prefix . 'credit_limit_amount',
                'type'     => 'text',
                'required' => true,
                'columns'  => 4,
            ],
        ],
    ];
    
    return $meta_boxes;
    }
    

    =================

    With the code above, I want to get the value of the settings in function.php but rwmb_meta() return null.

    According to this page, https://support.metabox.io/topic/code-not-working-with-updated-version/

    I also tried get_option():
    $test1 = get_option( 'limit_settings' )['credit_limit_amount'];
    $test1 is still null.

    WordPress v5.9
    Meta Box v5.5.1
    Meta Box AIO v1.15.5

    Please help.

    #33477
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The option_name of the settings page should be limit_settings. Please correct it and get the value again. Refer to this documentation https://docs.metabox.io/extensions/mb-settings-page/#using-code

    #33479
    vary@ifoundries.com[email protected]
    Participant

    It is working now, many thanks.

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