Custom Fields
Re-Envisioned
Support MB Settings Page rwmb_set_meta in for Settings page field

  • Creator
    Topic
  • #19425
    Resolved nolab
    Participant

    Hi!

    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?

    Thanks!!

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

    Hi,

    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 https://developer.wordpress.org/reference/functions/update_option/

    #19457
    nolab
    Participant

    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.

    Best!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
grid gear info copy caret-up caret-down trash