Custom Fields
Re-Envisioned
Support MB User Meta Optimize rwmb_meta_boxes filter

This topic contains 4 replies, has 3 voices, and was last updated by  Anh Tran 1 year, 9 months ago.

  • Creator
    Topic
  • #6372
    Resolved
    woorise
    Participant

    Hello,

    I am using the following code to add terms to user profile but the coding is loading everywhere. What is the recommended way to optimize and load it only where we need it (maybe on profile page only)?

    https://pastebin.com/zC2eqAhY

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #6373

    Jackky
    Participant
    if (is_admin()) {
       add_filter( 'rwmb_meta_boxes', 'user_profile' );
    }
    #6379

    Anh Tran
    Keymaster

    What @jackky recommended is correct. However, in that case you can’t use rwmb_meta for users in the frontend (yes, it works). get_user_meta is totally fine.

    #6382

    woorise
    Participant

    Thank you for your answers. Most of the times I am using get_user_meta or get_post_meta.

    My users have access mostly on backend and even using is_admin() it will still load for example in the dashboard.

    #6385

    Anh Tran
    Keymaster

    I got it. The thing is we couldn’t load the meta box or fields for a specific page in admin. Because the code need to run not only when showing fields, but also when saving fields. And the saving part requires to be run on admin in general.

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.