Skip to content

Instantly share code, notes, and snippets.

@danielpataki
Last active February 6, 2018 06:25
Show Gist options
  • Save danielpataki/d0f8b862996088491820 to your computer and use it in GitHub Desktop.
Save danielpataki/d0f8b862996088491820 to your computer and use it in GitHub Desktop.
Roles And Caps
add_role( 'company', 'Company', array( 'read' => true, 'level_0' => true, 'view_ad_stats' => true ) );
function custom_role_company() {
$author = get_role( 'author' );
$capabilities = $author->capabilities;
$company = add_role( 'company', 'Company', $capabilities );
$company->add_cap( 'view_ad_stats' );
}
register_activation_hook( __FILE__, 'custom_role_company' );
$user = new WP_User( 23 );
$user->add_cap( 'view_ad_stats' );
add_action( 'admin_menu', 'my_seo_plugin_menu_item' );
function my_seo_plugin_menu_item() {
add_menu_page(
'My SEO Plugin Options',
'My SEO Plugin',
'manage_options',
'my-seo-plugin-general',
'my_seo_plugin_menu_page',
'dashicons-visibility',
6
);
}
<?php if( current_user_can( 'manage_options' ) ) : ?>
<a href='#'>delete all SEO data</a>
<?php endif ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment