Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent users from creating new WordCamp and Meetup posts on central dashboard #1048

Merged
merged 5 commits into from
Sep 29, 2023

Conversation

timiwahalahti
Copy link
Collaborator

@timiwahalahti timiwahalahti commented Sep 20, 2023

Prevent users from creating new WordCamp and Meetup posts on dashboard. In most of the cases, all posts should be created thru the public application forms in order to get all needed information and to initiate the vetting process correctly.

Expectation is made for users with wordcamp_wrangle_wordcamps and wordcamp_wrangle_meetups capabilities, as deputies need to create events manually from time to time.

Fixes #728, See #734 and #1041 and #950 (this is retry of it) and #1031 (which reverted 950)

Props @NewYorkerLaura @iandunn

How to test the changes in this Pull Request:

  1. Log in as user with contributor role
  2. Send a WordCamp application via public form https://central.wordcamp.test/wordcamp-organizer-application/
  3. Log out and log in as user with admin or deputy role
  4. Navigate to https://central.wordcamp.test/wp-admin/edit.php?post_type=wordcamp and you should see the application just sent
  5. Navigate to https://central.wordcamp.test/wp-admin/post-new.php?post_type=wordcamp and you should be able to create a new WordCamp
  6. Add the user with contributor role to the site
  7. On wp-config.php $wcorg_subroles array remove wordcamp_wrangler and meetup_wrangler subroles from contributor role user
  8. Log out and log in as user with contributor role
  9. Navigate to central dashboard and try to update the WordCamp you send application for
  10. Check that you don't see "Add new" button on WordCamp listing

@timiwahalahti timiwahalahti added [Priority] 1 [Component] WCPT WordCamp and meetup post types, applications, trackers, mentors labels Sep 20, 2023
@iandunn
Copy link
Member

iandunn commented Sep 21, 2023

🤔 I think it may be simpler to take advantage of Core's built in access controls, and add something like this to the post type registration:

'capabilities' => array(
	// `read` and `edit_posts` are intentionally allowed, so organizers can edit their own posts (but not others').
	'create_posts'           => 'wordcamp_wrangle_wordcamps',
	'delete_posts'           => 'wordcamp_wrangle_wordcamps',
	'delete_others_posts'    => 'wordcamp_wrangle_wordcamps',
	'delete_private_posts'   => 'wordcamp_wrangle_wordcamps',
	'delete_published_posts' => 'wordcamp_wrangle_wordcamps',
	'edit_others_posts'      => 'wordcamp_wrangle_wordcamps',
	'edit_private_posts'     => 'wordcamp_wrangle_wordcamps',
	'edit_published_posts'   => 'wordcamp_wrangle_wordcamps',
	'publish_posts'          => 'wordcamp_wrangle_wordcamps',
	'read_private_posts'     => 'wordcamp_wrangle_wordcamps',
),

What do you think?

@timiwahalahti
Copy link
Collaborator Author

Makes a ton of sense. Started to over-engineer since the edit_published_posts made me a little weary of not having situations where the organiser updates their post, and it goes back to odd status. Now that I tested, it does not seem to be the case.

Will refresh the PR.

Copy link
Member

@iandunn iandunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@iandunn iandunn merged commit aa91ca4 into WordPress:production Sep 29, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] WCPT WordCamp and meetup post types, applications, trackers, mentors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not allow creating WordCamps in central for other than deputies
2 participants