Assigning user with custom role as author to posts in WordPress

If you have a user with custom role (read this post about roles and capabilities), you will not able to assign it as author to a post. This is due to a WordPress bug.

For now, there’s a workaround: add level_1 capability to your custom role.

Method 1

add_role('custom_role', 'Custom Role', array(
    'level_1' => true

Method 2

$role = get_role('custom_role');

Notice: if you already had users in your Wordpres, to take effect you need to temporary change user’s role to another role, save and then back to your custom role.



Category BootstrapCategory CoffeescriptCategory DrupalCategory GravCategory HTMLCategory JavascriptCategory JoomlaCategory jQueryCategory LaravelCategory MagentoCategory PHPCategory SharePointCategory SpringCategory ThymeleafCategory WordPressCategory Workflow


Developed and designed by Netgloo
© 2019 Netgloo