$role = get_role( 'editor' ); $role->add_cap( 'edit_others_posts' );In this example, we are granting the 'editor' user role the ability to edit other user's posts. This code should be placed in your theme's functions.php file or a custom plugin. The PHP 'add_cap' function is part of the WP_User class in WordPress. It is included in the WordPress core package library and is available by default for all WordPress installations.