Skip to content

Instantly share code, notes, and snippets.

@ericnicolaas
Last active June 5, 2020 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericnicolaas/0021bfecf925b5d95402e41db2971f28 to your computer and use it in GitHub Desktop.
Save ericnicolaas/0021bfecf925b5d95402e41db2971f28 to your computer and use it in GitHub Desktop.
Attendee fields
<?php
$fields_api->register_field(
new Charitable_Campaign_Field(
'attendees',
[
'label' => 'Attendees',
'data_type' => 'meta',
'admin_form' => [
'required' => false,
'section' => 'hike-details',
'type' => 'content',
'base_path' => __DIR__,
'view' => 'attendees-admin-field.php'
],
'campaign_form' => [
'required' => false,
'section' => 'campaign-details',
'type' => 'content',
'priority' => 20,
'fullwidth' => true,
'content' => 'content goes here'
],
'show_in_export' => true,
]
)
);
@ericnicolaas
Copy link
Author

Note: In the admin_form section I set it up so you can create a view file for the field in the admin. To do that, add the above code to the Charitable Hikes plugin you have, and add a new file called attendees-admin-field.php.

In that field, you can get the array of attendees like this:

global $post;

$campaign = new Charitable_Campaign( $post );
$attendees = $campaign->get( 'attendees' );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment