Friday, June 3, 2011

Roles and Capabilities

if ( current_user_can('contributor') && !current_user_can('upload_files') )

add_action('admin_init', 'allow_contributor_uploads');
function allow_contributor_uploads() {

$contributor = get_role('contributor');

$contributor->add_cap('upload_files');

}
if ( current_user_can('contributor') && !current_user_can('publish_pages') )

add_action('admin_init', 'allow_contributor_pages');
function allow_contributor_pages() {

$contributor = get_role('contributor');

$contributor->add_cap('publish_pages');

}
if ( current_user_can('contributor') && !current_user_can('edit_published_pages') )

add_action('admin_init', 'allow_contributor_edit_pages');
function allow_contributor_edit_pages() {

$contributor = get_role('contributor');

$contributor->add_cap('edit_published_pages');

}


if ( current_user_can('contributor') && !current_user_can('publish_posts') )

add_action('admin_init', 'allow_contributor_posts');
function allow_contributor_posts() {

$contributor = get_role('contributor');

$contributor->add_cap('publish_posts');

//wp_redirect(get_option('siteurl').'/wp-admin/edit.php?post_type=wpsc-product');

}

if ( current_user_can('contributor') && current_user_can('edit_published_pages') )

add_action('admin_init', 'allow_contributor_notedit_pages');

function allow_contributor_notedit_pages() {

$contributor = get_role('contributor');

$contributor->remove_cap('edit_published_pages');

}



http://codex.wordpress.org/Roles_and_Capabilities
http://camwebdesign.com/techniques/wordpress-role-capability-restriction/
http://camwebdesign.com/techniques/wordpress-create-custom-roles-and-capabilities/

No comments:

Post a Comment