What’s your most obscure WordPress knowledge?

What’s Your Most Obscure WordPress Knowledge?

Recently, a friend reached out to ask about setting up author switching for pages, a feature that exists for posts. Several years back, I dedicated numerous hours discovering that granting the “level_1” capability to the author role enables someone to change the author of a page via the edit or quick edit screens.

Interestingly, this method still holds true today. Sharing this here for those who may find it useful.

Update: Thanks to everyone for contributing to this enlightening and fun discussion!


One response to “What’s your most obscure WordPress knowledge?”

  1. Certainly! The ability to change the author of a WordPress page can be a bit obscure because, by default, WordPress primarily associates author management with posts rather than pages. However, it is possible to grant certain capabilities to specific user roles, allowing them to change the authors of pages as well. Here’s a detailed explanation of how to set this up, along with additional context:

    Understanding Roles and Capabilities in WordPress

    WordPress uses a system of roles and capabilities to control what users can and cannot do. Each user role (such as Subscriber, Contributor, Author, Editor, and Administrator) comes with its own set of capabilities by default. However, WordPress is highly customizable, and these capabilities can be modified to suit your needs.

    The author Role and Pages

    By default, the author role can create and manage their own posts but not pages. However, you can extend this role’s capabilities to allow them to change the author of a page. To facilitate author switching on pages, you can grant the level_1 capability to those roles. This is a lesser-known trick but can be quite useful.

    Implementing Author Switching for Pages

    Here is a step-by-step guide on how you can allow author switching for pages:

    1. Modify User Capabilities:
      You can use a plugin like “User Role Editor” or write a custom function to alter user capabilities. Here, I’ll demonstrate how to add the level_1 capability using custom code in a plugin or a themeโ€™s functions.php file.

    2. Adding the Code:
      Add the following code to your theme’s functions.php file or create a custom plugin for cleaner management.

    “`php
    function add_custom_capability_to_author() {
    // Get the role object.
    $role = get_role( ‘author’ );

       // Check if the role exists and add capability.
       if ( $role ) {
           $role->add_cap( 'level_1' );
       }
    

    }
    add_action( ‘init’, ‘add_custom_capability_to_author’ );
    “`

    1. Check for the Capability:
      After adding the capability, authors should now be able to change the authors of pages. To do this from the edit or quick edit screens:
    2. Go to Pages > All Pages in the WordPress dashboard.
    3. Select a page and click **Edit

Leave a Reply

Your email address will not be published. Required fields are marked *