Quick Summary

When managing a content-heavy WordPress website, handling author attribution can become a complex task, especially when dealing with posts written by individuals no longer actively involved with the site. The native WordPress user system ties authorship to user accounts, posing challenges in terms of security, recognizing multiple authors per post, and managing author profiles.

To address these issues, this article explores a developer-focused solution that decouples content authorship from the WordPress user system by introducing a custom “Team Member” post type. It’s best to build it right the first time, but for those who are remodeling an existing site, I built a custom plugin designed to streamline the authorship migration process. You can find it at https://github.com/grayayer/migrate-wp-authorship/

This tutorial includes the initial setup, pre-migration steps, and the automated association of existing posts with their corresponding team member authors. Code snippets and detailed instructions are included.

Why would I want to do this?

  1. Improved Security: By decoupling the author display from the user accounts required for logging into the WordPress admin area, you can remove active user accounts for individuals who no longer need access to the site’s backend. This reduces the potential attack surface and enhances overall security.
  2. Better Management of Multiple Authors: The native WordPress user system is limited in its ability to handle multiple authors for a single post or page. By utilizing a custom “team member” CPT with a relationship field, you can easily associate multiple authors with a piece of content, providing proper recognition to all contributors.
  3. Enhanced Author Profiles: A dedicated “team member” CPT allows you to create rich, detailed profiles for each author, including biographies, photos, job titles, and other relevant information. These author profiles can be leveraged for SEO purposes and to provide additional context to readers.
  4. Future-Proofing: Separating the author display from the WordPress user system future-proofs your content authorship management. If an author leaves the company or changes roles, you can easily update their “team member” post without affecting the underlying user account or disrupting the content attribution.
  5. Consistent Branding and Design: By using a custom “team member” CPT, you have greater control over the display and styling of author information on the front-end, ensuring consistency with your overall branding and design.
  6. Scalability: As your content team grows, managing author profiles and associations through a dedicated CPT can be more scalable and efficient compared to relying on the WordPress user system, which is primarily designed for administrative purposes.
  7. Data Integrity: By automating the process of associating posts with “team member” posts, you can reduce the risk of human error and ensure consistent data integrity across your content authorship records.

Within your website, you can then go from having simple bylines as shown in this example

to more robust multi-author bylines such as

Who is this Appropriate for?

Large Enterprises and Corporations

  • Companies with a sizeable content marketing team or dedicated writers/authors separate from the web team managing the WordPress site.
  • Organizations where multiple individuals contribute to a single piece of content, requiring proper attribution for all authors.
  • Businesses with frequent employee turnover or role changes, necessitating a seamless transition of content ownership without disrupting author attribution.

News and Media Organizations

  • Online news publications, magazines, or blogs with a large pool of writers and contributors.
  • Media sites that frequently publish articles or stories with co-authors or multiple bylines.
  • News outlets with stringent security requirements and a need to limit active user accounts for former employees or external contributors.

Educational Institutions and Research Organizations

  • Universities, colleges, or research centers where academic papers, articles, or publications are authored by multiple researchers, professors, or students.
  • Institutions with a high volume of scholarly content and a need for accurate author attribution and profiles.

Membership Organizations and Professional Associations

  • Organizations that publish content contributed by their members, staff, or industry experts.
  • Associations that need to maintain accurate author profiles and attribution for thought leadership pieces, whitepapers, or industry publications.

Websites with Strict Branding and Design Standards

  • Companies or organizations with specific branding guidelines and design requirements for author bylines and profiles.
  • Sites that need to customize the display and styling of author information to align with their overall brand identity.

The Backstory

I was brought on to rehab a WordPress (WP) website for an enterprise company focused heavily on content marketing. I was presented with a unique challenge. The technical blog had amassed over 500+ articles, many of which were written by individuals who had since left the company. However, because authorship was being recognized in the front-end design by utilizing the native WP user system, it created a problem when an author departed. Either their user account had to remain active, posing a potential security risk, or their authorship had to be reassigned to a generic profile, diminishing the recognition for their contributions.

In line with the philosophy of minimizing active user accounts for those who don’t require backend access, aka the principle of least privilege, I sought a solution that would decouple author attribution from the WP user system. Additionally, there were instances where multiple authors collaborated on a single article, and the existing solution involved utilizing Advanced Custom Fields (ACF) to add a user ID field to the posts, which is a type of relationship field. While this allowed for recognizing multiple contributors, it didn’t address the underlying issue of user account management.

A common practice for organizational and business websites is to feature team member biographies, particularly for C-suite individuals. These dedicated pages not only provide recognition but also offer SEO benefits. We already had a “team member” custom post type (CPT), so the next step was to generate a team post for each article author, add an ACF relationship field to blog posts for assigning team posts, and reassign the ownership of articles to these new team member posts.

With over 500 posts requiring processing, manually assigning team members would have been inefficient and prone to errors. Therefore, I developed a custom developer’s plugin to automate and streamline this migration process systematically and thoroughly.

As we’re already extensively using Advanced Custom Fields Pro for theme development, I added what some may consider an unnecessary extra step, in which I’m adding an ACF WordPress User field to each team member. This allows us to directly link team members to their corresponding WordPress user profile. This is in preparation for performing some DB operations where I programmatically add a team member relationship to each blog post.

I considered just trying to associate Team post titles to user names directly but this is:

  • More straightforward and reliable queries based on user IDs, which are unique and indexed, leading to better performance.
  • Easier to manage and maintain relationships, as IDs are less prone to errors than names.

Pre-Plugin Installation Instructions

Since my plugin is developed for developers with this niche problem, it’s not exactly “plug-n-play”.

Team Member Custom Post Type

If you don’t already have a “team CPT, create the CPT to represent your team members. You can use a plugin like “Custom Post Type UI” or add the following code to your dedicated site specific functionality plugin.

PHP
function create_team_custom_post_type() {
    register_post_type('team',
        array(
            'labels' => array(
                'name' => __('Team Members'),
                'singular_name' => __('Team Member')
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'team'),
            'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields')
        )
    );
}
add_action('init', 'create_team_custom_post_type');

Here’s your reminder that WP best practice is:

Just because you can build plugin-like features in a theme doesn’t mean you always should, particularly if you are distributing your theme to others to use. If you are creating features that should be available regardless of the site’s design, it is best practice to put the code in a plugin. The rule of thumb is that themes should only deal with the site’s design.

https://developer.wordpress.org/themes/core-concepts/custom-functionality/

Advanced Custom Fields Work

Add a “wp_user” user field to the “team” CPT using Advanced Custom Fields (ACF). This field will associate each team member post with a WordPress user account. After you migrate the blog authorship, you can remove that field.

Next Add an “article_authors” relationship field to the blog post CPT (or any other post type you want to associate with team members). This field will allow you to select multiple team members as authors for each post.

You’re now ready to create some team member posts. While you could do this programmatically, in my case the names/headshots/titles of so many of the authors had changed so it was more prudent to manually create each team member post manually. I’ll likely be adding functionality to the plugin soon to auto-generate a team post for each WP user.

Within your single post editing backend, you should have an interface now like this:


Install the Plugin and follow these steps

Go to the Github repository for my Reassign WordPress Post Authors to Team Member CPT Plugin. Download it, and activate it.

Pre-Migration Steps

Step 1

Navigate to Tools > Team Member Sync in the WordPress admin area.

Click the “Scan for Missing Team Member Posts” button to generate a report of authors who don’t have corresponding team member posts. Create the missing team member posts before proceeding.

This tool will scan the “author” field array for any users that don’t have corresponding team members and output a report, so you can create the missing team member posts prior to running the sync tool. It will look like this:

Now you can go create those team members prior to the reassignment.

In case you’re afraid you might have missed

Step 2

Click the “Scan Team Members for Missing WP User ID” button to identify any team member posts that are missing an associated WordPress user ID.

Go back to your team posts, and designate the appropriate wp user for each team post that was missing one.

Step 3 Data Migration

Select the target post type (e.g., “Posts”) and the desired post status (e.g., “Published”) from the dropdowns.

Click the “Sync All” button to associate all posts with their respective team member authors. Alternatively, click “Sync Only New Posts” to update only the posts that haven’t been synced before.

Verification and Next Steps

Review the sync report to ensure that all posts were updated successfully.

Update the team member profiles with relevant information, such as biographies, photos, and job titles.

Incorporate the team member attribution in your theme by displaying the associated team member information instead of the native WordPress author information.

1 Comment

  1. Thanks Gray! We’ve been on the lookout for something like this. Our content creators usually just send Google Docs to the dev team anyway. Navigating the WP User functionality has been a bit awkward, especially since our team members collaborate frequently. Co-authorship has been a feature request for a few months now, so it’s great to have a handy solution that does even more.

Leave a Reply

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

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.