WordPress.org

Making WordPress.org

Opened 13 months ago

Last modified 8 months ago

#2940 assigned enhancement

WordCamp Attendee JSON

Reported by: codexdemon Owned by:
Milestone: Priority: low
Component: WordCamp Site & Plugins Keywords: needs-patch good-first-bug
Cc:

Description

Is there way to get JSON of WordCamp Attendee, was working on attendee page in android so i could not able to figure out WP Json for Attendee of Camptix

Attachments (2)

2940.1.diff (5.2 KB) - added by igmoweb 8 months ago.
2940.2.diff (4.8 KB) - added by igmoweb 8 months ago.

Download all attachments as: .zip

Change History (10)

#1 @SergeyBiryukov
13 months ago

  • Component changed from General to WordCamp Site & Plugins

#2 @coreymckrill
12 months ago

  • Keywords needs-patch good-first-bug added
  • Owner set to coreymckrill
  • Status changed from new to accepted

This would require creating a new plugin or enhancing the core CampTix plugin to add a new REST API endpoint for the tix_attendee post type. The controller for the endpoint would need to follow similar logic to the [camptix_attendees] shortcode to ensure that attendees marked as "private" do not get included in the response. There would also probably need to be a way within the UI to mark which questions/answers get included as fields in the REST response. And it would need to be possible to filter by ticket type.

This ticket was mentioned in Slack in #meta-wordcamp by coreymckrill. View the logs.


11 months ago

#4 @coreymckrill
10 months ago

  • Owner coreymckrill deleted
  • Status changed from accepted to assigned

#5 @iandunn
9 months ago

  • Priority changed from normal to low

#6 @igmoweb
8 months ago

Here's a first patch for the attendees endpoint. The patch exposes wp-json/wp/v2/tix_attendees endpoint and it can use the same parameters than the posts endpoint with some changes:

  • The endpoint includes a few fields like first name, last name and a list of avatars URLs.
  • It doesn't allow the per_page parameter (same than the [camptix] shortcode)
  • It won't display attendees marked as private

Not done yet:

  • Create a new tab in Camptix settings to select questions to display in the endpoint.
  • Add those fields in the response.

Still, without the questions, I think the endpoint is pretty usable already.

@igmoweb
8 months ago

#7 @iandunn
8 months ago

I haven't had a chance to look closely at the patch, but it looks to be going in the right direction at first glance.

We might want to use wcorg_register_meta_only_on_endpoint() from helper-functions.php, to avoid the privacy issues explained in that function's docblock. I can't think of a use case where exposing first/last names would be a big deal, but there could be one that I haven't thought of yet.

#8 @igmoweb
8 months ago

@iandunn

I'm uploading a new patch. I had to add 'custom-fields' to support array when the post type is registered. I'm not sure if there's any security concern about it but I had no other way if I wanted to return the meta array in the response.

The questions are still missing but I don't really know if adding a new tab in Camptix settings would worth it as I guess no WC organizer will care about the REST API. I think the Twitter username and site URL would be more interesting to add. I see that there are a few actions hooked into the attendees shortcode like camptix_question_field_twitter. I'm thinking if it would be a good idea to check if has_action( 'camptix_question_field_twitter' ) or similar and then display that field in the response or not. I can't think right now on another way to decide if the field should appear or not.

@igmoweb
8 months ago

Note: See TracTickets for help on using tickets.