Posted: May 14, 2015 at 9:12 pm
|
Hey EE – I’ve spent a long few hours trying to solve this, and I hope you have a simple, easy answer for me. ๐ How can I hook into the admin page load for your CPTs (specifically Events and Venues) to remove support for certain metaboxes – YOUR metaboxes? I’m trying to lock down the admin interface for my client. For their uses, Venues will only need a Title, Slug, Physical Location (City, State), and a custom field. Events will have similar limits. I am familiar with the remove_post_type_support function and remove_meta_box and I’ve successfully used both to remove default metaboxes from both Venues and Events (author, tags, editor, etc). But, I’m unsure of how to return a list of metabox objects for a given admin screen, so that I can remove them programmatically. I would very much prefer not to hide anything with CSS, but rather remove the metaboxes entirely when the admin page loads. FWIW, this customization can be applied for all users and roles in the site. Can you help me with this? |
|
Hi Phil, I understand how you felt! I roped one of our developers into helping me track down what to do to save some time. The EE Admin system has a lot of complicated functionality in it to support the feature requests customers have made so for some things its not as straightforward as normal WordPress admin page routes/functions. Here’s some example code to remove metaboxes from the Events and Venue routes: PLEASE NOTE: Currently EE expects data from the forms in those boxes when an event/venue is saved, and will likely throw an error if that data is not present. So removing the metaboxes completely will likely result in errors. If you want to retain any data that’s already on an event, or prevent the errors, you will need to ensure you print hidden form fields in the loaded page that have the existing data (or default data on new events/venues) OR you will need to hook into the save/update process to handle when there’s no expected data (and either preserve existing data in related tables or add default data that EE expects for other systems). If you need further help with this use case, it falls outside the services we provide with a support license and you will need to request custom development for more detailed assistance. Please use this provided code with caution and test your changes thoroughly on a development server first! https://github.com/eventespresso/ee-code-snippet-library/tree/master/admin
|
|
Woot! Used the snippet for Venues (so far) and it works perfectly. Thanks for the quick and complete response. Related Followup: For a couple of these metaboxes/groups, I would like to hide partial information. i.e. for Venues: Is there a filter to do this? |
Hi Phil, hiding parts of those metaboxes isn’t available at this time via a filter. However, that may be possible by adding some CSS to target specific areas with display none. — |
|
|
Got it. I will give that a try. Thank you! |
The support post ‘Removing EE Screen Options and Metaboxes programatically (for all users).’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.