Optimize rwmb_meta_boxes filter

Support MB User Meta Optimize rwmb_meta_boxes filterResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6372
    woorisewoorise
    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

    #6373
    JackkyJackky
    Participant
    if (is_admin()) {
       add_filter( 'rwmb_meta_boxes', 'user_profile' );
    }
    #6379
    Anh TranAnh 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
    woorisewoorise
    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 TranAnh 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 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.