black friday sale

Custom Fields
Re-Envisioned
Support MB Custom Table Getting field value – admin area

  • Creator
    Topic
  • #21459
    Resolved wgstjf
    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #21470
    Long 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
    wgstjf
    Participant

    Thanks for the heads up – worked perfectly 🙂

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