Posted: July 1, 2019 at 11:44 am
Greetings – I need to add a few more items of information to the event setup screen on the wordpress admin back-end. So these extra fields can be filled out as just part of the event setup (not on the registration page, or front-end). I don’t see an easy way to do this – how can I do this? Thanks, Mark |
|
Hi Mark, You can use the existing “Custom Fields” meta box. It works the same way as it does for regular WordPress posts. You’ll find more information about how to use Custom Fields here: https://wordpress.org/support/article/custom-fields/ Mentioned in the above support article, there are plugins that allow for more customized custom fields, and we recommend the Advanced Custom Fields plugin for this. |
|
Josh – Forgive me but I don’t see a “Custom Fields” box anywhere on the Event setup page, and I don’t have any posts setup. How/where do I find this meta box? THe info does not explain how to get to this box in the first place. Thanks – Mark |
|
Hi Mark, It’s there by default, so that’s why the information doesn’t explain how to add it. If it’s been removed, it can be added back by going to the Screen Options tab (upper right corner of the window) and then checking the box next to “Custom Fields”. |
|
If I am understanding you correctly there should be a “Custom Fields” option on the EE Event setup page? I don’t see one. I click on Screen Options and it doesn’t appear there either. I would send you a screenshot of what I am seeing but I don’t see a way to add an image to this post. Am I looking in the right place? |
|
Hi Mark, I wonder if your WordPress user account has a restriction that doesn’t allow for working with custom fields. Are you logged into the site with a admin level account that has access to all capabilities? |
|
Here’s some more information about access to the Custom Fields meta box: https://www.role-editor.com/access-to-custom-fields-post-meta/ |
|
Found the issue – If you have ACF plugin installed (which I do) then ACF by default removes the “Custom Fields” option from pages and posts because it assumes you want to use ACF instead. To re-enable this feature you have to add this code snippet to the functions.php file: add_filter(‘acf/settings/remove_wp_meta_box’, ‘__return_false’); That’s it – it works. NOW it see what you are talking about. So I will need to add the 3 new custom fields to every event page I have setup. There is no way to just define them once, and have them added to every Event setup page automatically? Thanks – Mark |
|
You can use Advanced Custom Fields (the plugin) to define them once for event setup pages. To add them without a plugin involves custom coding e.g. |
|
So I created 3 new custom fields into a group using ACF. They show up in their own section on the Event setup page (nice). Now in the back-end I need to pull those 3 custom field values. I was hoping they would be in the answers array (hanging off of the registration object) but no. How do I get to the 3 custom field values from my PHP? |
|
The custom field values are related to the event, they are not directly related to the registration. ACF provides functions for retrieving custom fields: https://www.advancedcustomfields.com/resources/the_field/ https://www.advancedcustomfields.com/resources/get_field/ There’s also a native WP function: https://developer.wordpress.org/reference/functions/get_post_meta/ and you can also access the value as a property of the event post: https://developer.wordpress.org/reference/functions/get_post_meta/#comment-1894 |
|
Josh – So like I stated above I have added 3 new custom fields into a group using ACF. The now display and can be filled out the Event setup page. In my PHP I have the following code: The fields names are correct. But I am getting empty results back on all 3 of the get_field calls. I tried adding a post id to the get_field calls using: Then I read something about being inside “the loop” vs being outside “the loop” so I tried this: But that doesn’t work either. Can you tell me what’s missing, or what i am doing wrong? Thanks – Mark |
|
Hi Mark, The current post ID would likely not be correct, because it sounds like this code is running on a page other than the event page. If you’re trying to get custom fields about the event while during the registration process, you’ll need to get the event ID from the transaction in progress. This is similar to the other topic you posted earlier this week.
|
|
Josh – Ok I have a EE_Event object now. It has a method called question_groups() that I think I call to get MY question group with my 3 custom fields. I tried passing in an array of 1 element (my question group name “MAX Required Fields”) to question_groups() but that error’ed out. Can you layout some code (or point me to some) that takes me from a EE_Event object, through my question group, down to the actual custom field answers please? Much appreciated – Mark |
|
Hi Mark, I’m a bit confused by your question because you mention question groups. Are these questions that are being asked on the registration form? If so, you’d get the answers via the registration object. If it’s the values from the custom fields within the event editor that you’re after, then you could use the get_post_meta() function or similar. |
|
Sorry, let me clarify. I needed to add 3 custom fields to the Event Setup screen in the EE back-end. I already had ACF so I created a new question group in ACF and added the 3 custom fields. They now show up in a new section in Event Setup. Now I need to pull those field responses in my PHP code and do some processing with them. So I need to know how to get at the custom field values that are entered during Event Setup. You indicated above that it starts with a EE_Event object? |
|
If your key name is
or you could use a method provided by Event Espresso:
or with a function provided by the ACF plugin:
|
|
The support post ‘EE4: How do add extra fields to the event setup screen?’ 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.