wordpress 權限


wordpress系統的用戶權限中,默認是不容許投稿者上傳圖片的。 php

要想更改投稿者角色的權限,讓投稿人也能夠上傳圖片,那麼要使用wordpress的add_role函數,爲投稿者角色添加文件上傳功能: wordpress

把下面的代碼加入到當前主題的functions.php文件中,便可爲contributor添加文件上傳功能
<!– 代碼 –> 函數

if( current_user_can('contributor') && !current_user_can('upload_files') )
   add_action('admin_init','allow_contributor_uploads');
 
   functionallow_contributor_uploads() {
      $contributor= get_role('contributor');
      $contributor->add_cap('upload_files');
}



一樣的道理,能夠更改代碼中的角色和權限,爲任何角色添加更多的權限。

比較要和做者角色添加編輯其它做者文章的權限可使用改變爲以下代碼: post

if( current_user_can('author') && !current_user_can('edit_others_posts') )
   add_action('admin_init','allow_contributor_uploads');
 
   functionallow_contributor_uploads() {
      $contributor= get_role('author');
      $contributor->add_cap('edit_others_posts');
}



更多的角色和權限請看wordpress的官方文檔

http://codex.wordpress.org/Roles_and_Capabilitie spa

相關文章
相關標籤/搜索