Skip to content

Instantly share code, notes, and snippets.

@imath
Created February 14, 2017 20:21
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 imath/8b8e25ef24624b28846687764352aac8 to your computer and use it in GitHub Desktop.
Save imath/8b8e25ef24624b28846687764352aac8 to your computer and use it in GitHub Desktop.
Allow editor to Manage/Moderate Ideas
<?php
/**
* What is the wp-idea-stream-custom.php file ?
* @see https://github.com/imath/wp-idea-stream/wiki/wp-idea-stream-custom.php
*/
function uana_map_to_editor( $caps, $cap, $user_id, $args ) {
/**
* Role > min cap.
* editor > edit_pages
* author > edit_published_posts
* contributor > edit_posts
*/
switch( $cap ) {
case 'read_idea' :
case 'read_private_ideas' :
case 'edit_idea' :
case 'edit_ideas' :
case 'edit_others_ideas' :
case 'edit_private_ideas' :
case 'edit_published_ideas' :
case 'delete_idea' :
case 'delete_ideas' :
case 'delete_others_ideas' :
case 'delete_private_ideas' :
case 'delete_published_ideas' :
case 'manage_idea_tags' :
case 'edit_idea_tags' :
case 'delete_idea_tags' :
case 'manage_idea_categories' :
case 'edit_idea_categories' :
case 'delete_idea_categories' :
$is_admin_cap = reset( $caps );
if ( 'manage_options' === $is_admin_cap ) {
$caps = array( 'edit_pages' );
}
break;
}
return $caps;
}
add_filter( 'wp_idea_stream_map_meta_caps', 'uana_map_to_editor', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment