Getting field value - admin area

Support MB Custom Table Getting field value - admin areaResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #21459
    wgstjfwgstjf
    Participant

    Hi guys,

    Can you confirm something for me? Does the helper function to get custom meta, from custom tables, (https://docs.metabox.io/extensions/mb-custom-table/#getting-field-value) only work in the frontend? Can't seem to get it to work in the admin area.

    If this is the case, is it by design? If so, what do you recommend as an efficient/optimised way to get custom meta stored in a custom table?

    Cheers,

    Will

    #21470
    Long NguyenLong Nguyen
    Moderator

    Hi Will,

    The helper function can get the field's value in the admin area that is stored in the custom table. But you need hooking to init with the higher priority such as 99 or a hook fires after init to make sure the table and meta boxes are registered. Here is the sample code:

    add_action( 'init', function() {
        $field = rwmb_meta( $field_id, ['storage_type' => 'custom_table', 'table' => $table], $post_id );
    
        echo "<pre>";
        print_r($field);
        echo "</pre>";
    
    }, 99 );

    For more WordPress Hooks Firing Sequence information, please follow this article http://rachievee.com/the-wordpress-hooks-firing-sequence/.

    #21475
    wgstjfwgstjf
    Participant

    Thanks for the heads up - worked perfectly 🙂

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