Last active
February 6, 2018 06:25
-
-
Save danielpataki/d0f8b862996088491820 to your computer and use it in GitHub Desktop.
Roles And Caps
This file contains 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
add_role( 'company', 'Company', array( 'read' => true, 'level_0' => true, 'view_ad_stats' => true ) ); |
This file contains 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
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' ); |
This file contains 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
$user = new WP_User( 23 ); | |
$user->add_cap( 'view_ad_stats' ); |
This file contains 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
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 | |
); | |
} |
This file contains 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 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