Support

Home Forums Event Espresso Premium Adding persistent fields to event & adding more fields to user record

Adding persistent fields to event & adding more fields to user record

Posted: July 30, 2018 at 10:34 am


ICLE

July 30, 2018 at 10:34 am

The use of ‘custom field’ in EE is great, but I would also like to add fields that do not need to be selected each and every time an event is created and let them have default values. What is the best way to do this? Would Advanced Custom Fields be a solution?

I have tried them once and they made all my original “custom fields” vanish. Is that how this is supposed to work?

I also have a need to extend the user record with several fields like middle name, Bar number, VIP type etc… Is that best done with the “toolset” plugin since that is a core record type? I want to be sure the fields are accessible to the eventespresso templated email and printed outputs as shortcode.


Josh

  • Support Staff

July 31, 2018 at 8:26 am

Hi,

What is the best way to do this? Would Advanced Custom Fields be a solution?

Advanced Custom fields can do that. I’ve not seen it where ACF makes original custom fields vanish, that’s not what it does on my testing site.

Another approach would be to add this code snippet to your functions file:

add_action('wp_insert_post', 'my_ee_set_default_custom_fields');
function my_ee_set_default_custom_fields($post_id){
    if ( did_action('auto-draft_espresso_events')) {
        add_post_meta($post_id, 'field_name', 'my default value', true);
    }
    return true;
}

You’ll change field_name and my default value to match your desired default custom fields and values.

With regards to user records, if you want the fields to be accessible to Event Espresso email templates as shortcodes, then currently the only option is to use admin-only questions. You can add admin-only questions to a question group, then assign the group to the event. Then you’ll be able to add values to those fields to the registration record and display them in emails with shortcodes:
[RECIPIENT_ANSWER_*question text]
and
[PRIMARY_REGISTRANT_ANSWER_*question text]

Currently the Event Espresso email templates do not have user meta-type shortcodes.


ICLE

August 6, 2018 at 6:45 am

I will try ACF again.
I want to keep these things in plugins so others can pick up the pieces when I get hit by the bus.
If ACF still gives me problems I will go get the snippet training on lynda and hack away.

Is the toolset plugin another option? I am just getting into wordpress development and am unfamiliar with the best practices… but earnestly learning!

Thanks!


Josh

  • Support Staff

August 6, 2018 at 10:42 am

Toolset is probably more complexity than what you need to add fields to an event and even a user record.

The support post ‘Adding persistent fields to event & adding more fields to user record’ 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.

Event Espresso