PHP code example of rockschtar / wordpress-role
1. Go to this page and download the library: Download rockschtar/wordpress-role library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rockschtar / wordpress-role example snippets
// describe role
use Rockschtar\WordPress\Role\Role;
class FAQManagerRole extends Role
{
public function roleName(): string
{
return 'faq-manager';
}
public function capabilities(): array
{
return [
'edit_faq',
'read_faq',
'delelte_faq'
];
}
public function displayName(): string
{
return __('FAQ Manager', 'my-textdomain');
}
}
//register role hook
register_activation_hook(MY_PLUGIN_FILE, 'myprefix_register_faq_role');
function myprefix_register_faq_role() {
FAQManagerRole::register();
}
//unregister role hook
register_deactivation_hook(MY_PLUGIN_FILE, 'myprefix_unregister_faq_role');
function myprefix_unregister_faq_role() {
FAQManagerRole::unregister();
}