custom roles, php | WordPress.org

[ad_1]

I have created a number of customer roles which show up and can be selected in your checkbox UI. They don’t get saved though. Non-custom ones do get saved.

I’m on PHP 8.3 and WordPress 6.5.3 , nothing shows in the PHP error log.

//============================================================================
function AddBungalookRole($RoleName, $RoleOptions)
// CREATE ROLES
//============================================================================
{
add_role("Bungalook_{$RoleName}", "Bungalook {$RoleName}", $RoleOptions);
}
//============================================================================
function CreateBungalookUserSecurityRoles()
// CREATE ROLES
//============================================================================
{
$RoleOptions = [
'read' => true,
'create_posts' => true,
'edit_posts' => true,
'edit_others_posts' => true,
'publish_posts' => true,
'manage_categories' => true,
];
AddBungalookRole('Newsletters', $RoleOptions);
AddBungalookRole('Orders', $RoleOptions);
AddBungalookRole('Plants', $RoleOptions);
AddBungalookRole('Reimbursements', $RoleOptions);
}
add_action( 'init', 'CreateBungalookUserSecurityRoles' );

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer