Key Value (Field) add new data in php

Support General Key Value (Field) add new data in phpResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22309
    GAETANLAGARDEGAETANLAGARDE
    Participant

    Hi,

    I'm trying to add a "key value" to user :
    rwmb_set_meta($speaker_id,'mail_key_onboarding_1',array( 'key' => $live_id, 'value' => 1 ),array('object_type' => 'user'));

    It's not working via php,

    Although the box are ok in the admin gui,

    What did I miss please ?

    Gaetan

    #22315
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The function rwmb_set_meta() helps you to set a field value and save to the database, so the third argument must be a number, string, or serialized string.

    The code should be:

    add_action( 'init', function() {
        rwmb_set_meta($speaker_id,'mail_key_onboarding_1','string_or_number',array('object_type' => 'user'));
    }, 99 );
    

    For more information, please follow the documentation.
    https://docs.metabox.io/database/
    https://codex.wordpress.org/Database_Description

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