• Resolved Mark Woodard

    (@woodardmc)


    Hello,

    I’m working on an integration with meta box that will let users pick Meta Box field groups and fields from a selector. After selecting a field, it’s contents would displayed on the page.

    I’m stuck on displaying fields that are attached to a settings page though. To display a field from a settings page you need the “option name” for the field group it’s in.

    I don’t know what meta boxes might be on any given site. So I’ve been getting the field groups with the rwmb_get_registry( 'meta_box' )->all() function. This gets me all the field groups and their settings. But there doesn’t appear to be a way to get what locations or, in my case, settings pages that the field group is on.

    without getting the settings page that a field is on, I can’t get the option name and I can’t display it.

    Do you have any suggestions for how I could get these option names programmatically? Any help or guidance would be greatly appreciated.

    Thank you,

    Mark

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Anh Tran

    (@rilwis)

    Hi @woodardmc

    Sorry for the late reply.

    In the meta box object that you get through the rwmb_get_registry( 'meta_box' )->all(), the object type will define what type of the object this meta box is for. If for settings page, then $meta_box->get_object_type() === 'setting'.

    You can get the setting pages ID via $meta_box->settings_pages. All settings pages are added via the filter mb_settings_pages, so you can loop through it and find the settings page with the corresponding ID, and from that get the option name.

    Hope that helps,
    Anh

    Thread Starter Mark Woodard

    (@woodardmc)

    @rilwis

    Thanks for the pointer!
    I’ll give that a try and let you know if that works out for my case.

    Mark

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get a Field Group’s locations programmatically’ is closed to new replies.