cliff
3/10/2016 - 6:44 PM

Allow Subscribers (technically anyone who can access the CE form) to Add New Venue for The Events Calendar Community Events add-on

Allow Subscribers (technically anyone who can access the CE form) to Add New Venue for The Events Calendar Community Events add-on

<?php
/**
  * From https://gist.github.com/cliffordp/5708d5b5c1a8f36635a5
  * From Barry
  * 
  * Allow Subscribers (technically anyone who can access the CE form) to Add New Venue for The Events Calendar Community Events add-on
  * 
  * Here's a view of what Contributor users have permission to do: http://cl.ly/1M0c1u2x462a
  * If you want Subscribers to be able to Add New Venue, you could enable them to have `edit_tribe_venues` permission, which could be accomplished by using a plugin like https://wordpress.org/plugins/user-role-editor/ (third party, not guaranteed) or via this custom code snippet (resolves CE capabilities issue)
  * 
  * @link: https://developer.wordpress.org/plugins/users/roles-and-capabilities/
  */
add_action( 'init', 'barry_all_can_add_new_venue' );

function barry_all_can_add_new_venue() {
  $anon_users = Tribe__Events__Community__Main::instance()->anonymous_users;
  add_action( 'tribe_events_community_form', array( $anon_users, 'add_venue_org_caps' ) );
  add_action( 'tribe_ce_before_event_submission_page', array( $anon_users, 'add_venue_org_caps' ) );
  add_filter( 'user_has_cap', array( $anon_users, 'filter_venue_org_caps' ), 10, 3 );
}