The populate_roles_230() WordPress PHP function creates and modifies WordPress roles for WordPress 2.3.
Usage
To use the populate_roles_230() function, simply call the function like this:
populate_roles_230();
Parameters
- None
More information
See WordPress Developer Resources: populate_roles_230
This function is specifically for WordPress 2.3. For later versions, consider using other related functions.
Examples
Creating Default Roles for WordPress 2.3
Create default roles for a WordPress 2.3 installation.
// Call the populate_roles_230() function populate_roles_230();
Modifying the ‘Editor’ Role Capabilities
After creating the default roles, modify the ‘editor’ role to give it the capability to manage categories.
// Call the populate_roles_230() function populate_roles_230(); // Get the 'editor' role $editor_role = get_role('editor'); // Add 'manage_categories' capability to the 'editor' role $editor_role->add_cap('manage_categories');
Removing the ‘Author’ Role
Create default roles and remove the ‘author’ role from the WordPress 2.3 installation.
// Call the populate_roles_230() function populate_roles_230(); // Remove the 'author' role remove_role('author');
Adding a Custom Role
Create default roles and add a custom role called ‘content_creator’ with limited capabilities.
// Call the populate_roles_230() function populate_roles_230(); // Add a new custom role called 'content_creator' add_role('content_creator', 'Content Creator', array( 'read' => true, 'edit_posts' => true, 'delete_posts' => true, ));
Modifying the Capabilities of a Custom Role
Create default roles, add a custom role, and modify its capabilities.
// Call the populate_roles_230() function populate_roles_230(); // Add a new custom role called 'content_manager' add_role('content_manager', 'Content Manager', array( 'read' => true, 'edit_posts' => true, 'delete_posts' => true, )); // Get the 'content_manager' role $content_manager_role = get_role('content_manager'); // Add 'publish_posts' capability to the 'content_manager' role $content_manager_role->add_cap('publish_posts'); // Remove 'delete_posts' capability from the 'content_manager' role $content_manager_role->remove_cap('delete_posts');