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'); }
http://codex.wordpress.org/Roles_and_Capabilitie spa