Support

Home Forums Event Espresso Premium CSV export of "advanced custom field" values

CSV export of "advanced custom field" values

Posted: December 9, 2018 at 5:55 pm


ICLE

December 9, 2018 at 5:55 pm

https://eventespresso.com/topic/csv-export-of-event-custom-values-not-user-custom-values/

I got this to work but have not had success with getting advanced custom field values to export in the csv. Can you comment on this? Here is my code that works for custom fields:

add_filter( ‘FHEE__EE_Export__report_registrations__reg_csv_array’, ‘espresso_add_meta_value_csv’, 10, 2);
function espresso_add_meta_value_csv( $reg_csv_array, $reg_row ) {
// get the event’s ID
$event_id = $reg_row[ ‘Registration.EVT_ID’ ];
// example of getting the post meta
$cle_values = get_post_meta( $event_id, ‘cle_values’, true );
if ( $cle_values != ” ) {
$reg_csv_array[ ‘CLE Values’ ] = $cle_values;
$class_number = get_post_meta( $event_id, ‘class_number’, true );
if ( $class_number != ” ) {
$reg_csv_array[ ‘Class Number’ ] = $class_number;
}
return $reg_csv_array;
}

What should I change up for the advanced custom fields? I’ve tried the field names, but that did not seem to work very well… Where do I start with this?


Tony

  • Support Staff

December 10, 2018 at 6:25 am

Hi there,

Is that the full code? It appears to be missing a }

When you say it’s not working very well, what is actually happening with the export?


ICLE

December 10, 2018 at 6:40 am

That close bracket may have been the issue. I need to format this for ‘acf field’, not simply ‘custom fields’… can you help me model one field from acf fields into this syntax, then I can replicate and post and test.. thanks.


Tony

  • Support Staff

December 10, 2018 at 6:47 am

What is the ACF field type?

You can likely use get_field() however, the return type from that function depends on the field type in use.


ICLE

December 10, 2018 at 6:58 am

The only way I have used these area as shortcodes and they look like this:
[acf field="fieldname"] and the value of this record prints.


Tony

  • Support Staff

December 10, 2018 at 7:13 am

Ok, so are the fields just text fields?

ACF allows for different field ‘types’:

https://www.advancedcustomfields.com/resources/#field-types

They are still just ‘custom fields’ but the way the data within them is formatted is different depending on the type and how you pull the info you need changes depending on the field type.

If they are just text fields then the current code:

get_post_meta( $event_id, 'class_number', true );

(Assuming ‘class_number’ is the field name and it is just a basic text field holding an int)

Should just work, if not you’re going to need to do some extra work to pull the correct details from the field.


ICLE

December 10, 2018 at 7:22 am

Great. That is what I seek. You rock.


ICLE

December 10, 2018 at 7:36 am

Nope. Blew up the page. I am getting a http500 return.
Going to noodle over the resource link above to figure this out…


Tony

  • Support Staff

December 10, 2018 at 7:39 am

Post all of your code to a gist or pastebin so I can view it.

Please don’t post the code directly in the forum as it adds formatting so I then can’t tell if it’s your code or the forum formatting.


ICLE

December 10, 2018 at 10:56 am

Note that none of the Advanced Custom Fields may begin with a numeral.
Once I changed the name from “4d_program” to “fourd_program” it all worked fine.
You may close this ticket, it works fine now.

The support post ‘CSV export of "advanced custom field" values’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  ICLE 5 months, 1 week ago ago

Topic Tags

Tagged: ,

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!