Created
November 26, 2012 07:01
-
-
Save tobedoit/4146945 to your computer and use it in GitHub Desktop.
Wordpress: Role and Capability
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
/* 'Role' name change ******************************************************************************************** | |
** http://wordpress.stackexchange.com/questions/23026/is-there-way-to-rename-user-role-name-without-plugin **** */ | |
/* !회원 역할 이름 바꾸기 ***************************************************************************************** */ | |
function change_role_name() { | |
global $wp_roles; | |
if ( ! isset( $wp_roles ) ) | |
$wp_roles = new WP_Roles(); | |
//You can list all currently available roles like this... | |
//$roles = $wp_roles->get_names(); | |
//print_r($roles); | |
//You can replace "administrator" with any other role "editor", "author", "contributor" or "subscriber"... | |
$wp_roles->roles['administrator']['name'] = '최고관리자'; | |
$wp_roles->role_names['administrator'] = '최고관리자'; | |
$wp_roles->roles['editor']['name'] = '중간관리자'; | |
$wp_roles->role_names['editor'] = '중간관리자'; | |
$wp_roles->roles['author']['name'] = '학생교사'; | |
$wp_roles->role_names['author'] = '학생교사'; | |
$wp_roles->roles['subscriber']['name'] = '일반회원'; | |
$wp_roles->role_names['subscriber'] = '일반회원'; | |
} | |
add_action('init', 'change_role_name'); | |
/* Add roles **************************************************************************************************** | |
** http://stackoverflow.com/questions/8413560/wordpress-add-custom-roles-as-well-as-remove-default-roles ***** */ | |
/* !회원 역할 추가 ********************************************************************************************** */ | |
/* http://octalforty.com/articles/assigning-role-on-wordpress-registration-profile-page/ <= Additional Information ******* */ | |
add_role('장학생', '장학생', array( | |
'read' => true, | |
'edit_posts' => true, | |
'delete_posts' => true, | |
'edit_published_posts' => true, | |
'publish_posts' => true, | |
'delete_published_posts' => true, | |
)); | |
add_role('학부모', '학부모', array( | |
'read' => true, | |
'edit_posts' => true, | |
'delete_posts' => true, | |
'edit_published_posts' => true, | |
'publish_posts' => true, | |
'delete_published_posts' => true, | |
)); | |
/* !회원 역할 제거 */ | |
//remove_role('role'); | |
/* !역할의 능력 제거 & 추가 */ | |
/* http://wordpress.stackexchange.com/questions/12984/how-can-i-allow-the-editor-role-to-change-theme-settings */ | |
/* http://codex.wordpress.org/Roles_and_Capabilities */ | |
$editor = get_role('editor'); | |
$editor->remove_cap('manage_categories'); | |
$editor->remove_cap('edit_pages'); | |
$editor->remove_cap('edit_others_pages'); | |
$editor->remove_cap('edit_published_pages'); | |
$editor->remove_cap('manage_links'); | |
$subscriber = get_role('subscriber'); | |
$subscriber->add_cap('edit_posts'); | |
$subscriber->add_cap('delete_posts'); | |
$subscriber->add_cap('publish_posts'); | |
$subscriber->add_cap('edit_published_posts'); | |
$subscriber->add_cap('delete_published_posts'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment