Created
July 2, 2013 05:48
-
-
Save torounit/5907032 to your computer and use it in GitHub Desktop.
WordPress の User Role Editor 等で、カスタム投稿タイプに独自に権限設定する場合に、カスタム投稿タイプ用の権限を自動的に追加する。
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
<?php | |
function add_custom_post_type_role( $post_type ,$arg ) { | |
$role = get_role('administrator'); | |
if( "post" != $arg->capability_type and !$arg->_builtin ) { | |
$role->add_cap( "edit_{$arg->name}" ); | |
$role->add_cap( "read_{$arg->name}" ); | |
$role->add_cap( "delete_{$arg->name}" ); | |
$role->add_cap( "delete_{$arg->name}s" ); | |
$role->add_cap( "edit_{$arg->name}s" ); | |
$role->add_cap( "edit_others_{$arg->name}s" ); | |
$role->add_cap( "delete_others_{$arg->name}s" ); | |
$role->add_cap( "publish_{$arg->name}s" ); | |
$role->add_cap( "edit_published_{$arg->name}s" ); | |
$role->add_cap( "delete_published_{$arg->name}s" ); | |
$role->add_cap( "delete_private_{$arg->name}s" ); | |
$role->add_cap( "edit_private_{$arg->name}s" ); | |
$role->add_cap( "read_private_{$arg->name}s" ); | |
} | |
} | |
add_action( "registered_post_type", "add_custom_post_type_role", 10, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment