Repository navigation
Post Types, Blocks: let organisers list volunteers on the front end - #1987
Draft
alexandrebuffet wants to merge 1 commit into
Draft
alexandrebuffet wants to merge 1 commit into
alexandrebuffet wants to merge 1 commit into
Conversation
`wcb_volunteer` was the only participant post type registered as non-public, which left organisers with no supported way to show volunteers on the site: the CPT is filtered out of the Query Loop block's post-type control (that control only offers types `is_post_type_viewable()` accepts), and no block or variation covered it. The documented workaround was to stop using the CPT altogether and tag attendees with a CampTix admin flag instead. No rationale for the private registration is recorded, and the data model already assumed public exposure: `wcb_volunteer_team` has been registered with `'public' => true` against a private post type since it was introduced. Register volunteers like organisers -- public, `volunteers` REST base, shortlinks -- and add the pieces that make them renderable: a Volunteers List query variation, `avatar_urls` in the REST response, a `wordcamp/avatar` label, and a single template. Publishing the post type does not widen access to the volunteer's contact details: `_wcb_volunteer_email` and `_wcb_volunteer_first_time` are registered with `'context' => array( 'edit' )`, so they stay out of anonymous responses. A regression test pins that invariant. Fixes WordPress#1282 Claude-Session: https://claude.ai/code/session_0194BpoHzwSp719zHoEW5xuA Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1282.
wcb_volunteeris the only participant post type registered as non-public. Two consequences, both reported in the issue:is_post_type_viewable()accepts, so volunteers never appear in it.The workaround organisers are pointed at today is to abandon the CPT entirely and tag attendees with a CampTix admin flag instead.
This registers volunteers the same way organisers are registered, and adds the pieces that make them renderable:
wcb_volunteerbecomes'public' => true, gains'rest_base' => 'volunteers'andshortlinkssupport.core/queryvariation, mirroringorganizers-list(avatar + title, excerpt,wcb_volunteer_teamterms, pagination).avatar_urlsregistered onwcb_volunteerin the REST API — thewordcamp/avatarblock inside the variation reads it.wcb_volunteercase added to the avatar block's post label.single-wcb_volunteer.phpblock template, registered intheme-templates/bootstrap.php.How to review this PR
Suggested order:
wc-post-types.php→inc/rest-api.php→ the new variation →theme-templates.Three decisions worth surfacing rather than making you reverse-engineer them:
_wcb_volunteer_emailand_wcb_volunteer_first_timeare registered with'context' => array( 'edit' )(inc/rest-api.php), so publishing the CPT does not put volunteer contact details into anonymous REST responses.test_volunteer_contact_meta_is_not_exposed_to_anonymous_readerspins that invariant. This is the half of the change most worth a second opinion.public => truerather than a narrower flag.wcb_volunteer_teamhas been registered with'public' => trueagainst a private post type since it was introduced, so the data model already assumed public exposure. @o-samaras noted on the issue that no rationale for the private registration could be found; I couldn't find one either. If the meta team knows of a deliberate reason, that changes this PR substantially — say so and I'll rework it to keep the CPT private.rest_baseis a route change./wp/v2/wcb_volunteerbecomes/wp/v2/volunteers, matching the four sibling post types. Low risk while the CPT is non-public and undocumented, but it is a behaviour change and I'd rather flag it than bury it. Happy to drop it if you'd prefer.The variation uses the
hammerdashicon (the CPT's ownmenu_icon) rather than a custom SVG, since the four sibling variations use bespoke artwork I'm not in a position to design. A matching icon from design would be a welcome follow-up.Test plan
WordCamp Post Typessuite 56/56 passing (4 new)production(identical failure set; the 39 pre-existing failures are environmental: missingintlextension and the privatewporg-mu-pluginsrepo)productionper file)npm run buildinmu-plugins/blocks— clean;eslintclean on changed filesNew tests
public_html/wp-content/plugins/wc-post-types/tests/test-volunteer-public.php:wcb_volunteerpassesis_post_type_viewable()— the gate the Query Loop control uses./wp/v2/volunteersis registered.avatar_urlsfor everyrest_get_avatar_sizes()size.view-context response.Tests 1–3 fail against
productionand pass with this change. Test 4 passes both before and after by design — it's a regression guard on the invariant that makes publishing the post type safe, not a demonstration of new behaviour.Manual test steps (not yet executed)
wcb_volunteernow also appears in a plain Query Loop's post-type control./wp-json/wp/v2/volunteerslogged out; confirmavatar_urlsis present and no email address appears anywhere in the payload.