WP Manifestindependent plugin directory
manifest / users / multiple-profiles

Multiple Profiles

用這個 WordPress 外掛來建立多個作者個人資料,以在發佈內容時切換不同的發文身份。

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/huanyichuang/multiple-profiles/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Multiple Profiles - WordPress Plugin

用這個 WordPress 外掛來建立多個作者個人資料,以在發佈內容時切換不同的發文身份。

主要功能

  • ✅ 每個使用者可以建立最多 5 個作者個人資料
  • ✅ 在發佈文章時可以切換不同的作者身份
  • ✅ 顯示選取的作者身份的姓名和簡介
  • ✅ 自動退回到主要作者身份
  • ✅ 兼容所有 WordPress 主題 (已於 Blocksy 測試)

安裝

  1. 下載或複製這個 GitHub 儲存庫到 WordPress 外掛目錄:

    cd wp-content/plugins/
    git clone https://github.com/huanyichuang/multiple-profiles.git multiple-profiles
  2. 在 WordPress 管理介面中啟用外掛:

    • Navigate to Plugins → Installed Plugins
    • Find "Multiple Profiles" and click Activate

或者直接在 GitHub 下載外掛檔案,上傳到 WordPress 外掛目錄並安裝。

使用方法

建立作者身份

  1. 前往 [使用者 (Users)] > [個人資料 (Profile)]
  2. 往下捲動到 [多個作者身份 (Multiple Profiles)] 區段
  3. 按下 [新增作者身份 (Add New Profile)]
  4. 填寫作者身份的詳細資料:
    • 顯示名稱 (Display Name): 作者身份的顯示名稱 (必填)
    • 簡介 (Biography): 作者身份的簡介
    • Set as primary profile: Check to make this the default profile for new posts
  5. 按下 [更新個人資料 (Update Profile)]

切換作者身份

  1. 建立文章或編輯文章
  2. 在文章編輯畫面的右側找到 [作者身份 (Author Profile)] 區段
  3. 從下拉選單中選擇要使用的作者身份
  4. 發佈或更新文章

選取的作者身份的姓名和簡介將會顯示在前端,覆蓋原使用者的 WordPress 帳號名稱。

管理作者身份

  • 編輯: 點擊任何作者身份以編輯其顯示名稱或簡介
  • 刪除: 點擊 "Delete" 按鈕以移除作者身份
    • 使用已刪除作者身份的文章將會自動重新指派給主要作者身份
  • 設為主要作者身份: 選擇單選按鈕以將作者身份設為主要 (預設) 作者身份

運作原理

後端邏輯

本外掛將作者身份資料儲存在 WordPress 的 wp_usermeta 資料表中,使用 user_profiles 作為中繼資料鍵。每個文章選取的作者身份會儲存在 wp_postmeta 資料表中,使用 _author_profile_id 作為中繼資料鍵。

前端顯示

本外掛利用勾點覆蓋以下 WordPress 函式,以顯示作者身份資訊:

  • the_author() - 顯示作者身份的顯示名稱
  • get_the_author_display_name() - 回傳作者身份的顯示名稱
  • get_the_author_description() - 回傳作者身份的簡介
  • the_author_description() - 顯示作者身份的簡介
  • get_the_author_meta() - 過濾特定的中繼資料欄位

這確保了與大多數 WordPress 佈景主題相容,主要於 Blocksy 上測試。

檔案結構

multiple-profiles/
├── multiple-profiles.php          # Main plugin file
├── includes/
│   ├── class-profile-manager.php  # Profile CRUD operations
│   ├── class-post-profile.php     # Post-profile associations
│   ├── class-frontend-filters.php # Frontend display filters
│   └── class-admin-ui.php         # Admin interface
├── assets/
│   ├── css/
│   │   └── admin-styles.css       # Admin UI styles
│   └── js/
│       └── admin-scripts.js       # Admin UI JavaScript
└── README.md                      # This file

設定

最大作者身份數量

預設情況下,使用者最多可以建立 5 個作者身份。若要變更此限制,請編輯 includes/class-profile-manager.php 中的常數:

const MAX_PROFILES = 5; // 變更這個值

內容類型

本外掛預設支援所有公開內容類型,包括文章、頁面和任何自訂內容類型。作者身份選單會出現在所有這些內容類型的文章編輯器中。

相容性

WordPress 需求

  • WordPress 5.0 或更高版本
  • PHP 7.4 或更高版本

佈景主題相容性

本外掛與所有使用標準 WordPress 作者功能的佈景主題相容。已特別針對以下佈景主題進行測試:

  • Blocksy Theme ✅

本外掛會使用 WordPress 核心篩選器勾點,因此理論上應該會與任何符合規格的佈景主題相容。

安全性

本外掛實作了 WordPress 安全最佳實踐:

  • 所有表單提交都經過 Nonce 驗證
  • 權限檢查 (edit_user 用於個人資料管理)
  • 資料清理:sanitize_text_field(), wp_kses_post()
  • 輸出跳脫:esc_html(), esc_attr()
  • 儲存個人資料選擇前進行文章權限檢查

疑難排解

前端未顯示作者身份

  1. 清除網站和瀏覽器快取
  2. 檢查佈景主題是否使用自訂作者顯示程式碼
  3. 驗證文章是否已指派作者身份

文章編輯器中未出現作者身份選擇器

  1. 確保已在 /wp-admin/profile.php 建立至少一個作者身份
  2. 檢查文章類型是否為公開 (本外掛僅適用於公開內容類型)
  3. 重新整理頁面或清除瀏覽器快取

未顯示作者簡介

某些佈景主題使用自訂簡介函式。本外掛會篩選以下函式:

  • get_the_author_description()
  • the_author_description()
  • get_the_author_meta('description')

如果佈景主題使用其他自訂函式,可能需要新增自訂篩選器。

支援與開發

如果遇到任何問題,或需要其他功能、參與此專案開發:

  • 在 GitHub 上建立新的問題 (Issue)
  • 提交提取要求 (Pull Request)

授權

GPL v2 或更高版本

鳴謝

本專案利用 Claude Code 與 Gemini 3 Pro 協助開發。

更新日誌

Version 1.0.0

  • Initial release
  • Create up to 5 profiles per user
  • Profile selector for all post types
  • Frontend display filtering
  • Automatic profile reassignment on deletion