Custom Fields
Support MB Settings Page rwmb_set_meta in for Settings page field

  • Creator
  • #19425
    Resolved nolab


    And thanks in advance for your help.

    I'm trying to update a input field of a settings page, when a user click on a button in the admin (wp_ajax_ hook function).

    There I generate a json (it works) but I also want to update an input value with a value.

    I don't know if I can call rwmb_set_meta in this wp_ajax_action, or if I am using the correct syntax because I'm getting a 500 error.

    I have tried this:
    rwmb_set_meta( 'generalsettings', 'idgeneratedcdn', 'value', array( 'object_type' => 'setting' ));

    and this
    rwmb_set_meta( 'generalsettings', 'idgeneratedcdn', 'value');

    What am I doing wrong? the place I call the funcion or rwmb_set_meta for a settings page?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #19436
    Long Nguyen


    The function rwmb_set_meta() will be included in the next release. At this time, please try to use the function update_option() to update the settings page option.

    Here is the sample code

    add_action( 'init', function() {
        $settings_page = get_option( 'generalsettings' ); // the settings page ID
        $settings_page['idgeneratedcdn'] = 1000; // the field ID
        update_option( 'generalsettings', $settings_page ); // update
    } );

    For more information, please follow the documentation


    Hi Long!!

    Ok, good to know. Yes, I have done it as you suggest. Thanks!

    And good to know that rwmb_set_meta will be available soon.


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