2016-02-12 11 views
-1

嗯,我想要一些功能。你能聽到我的功能描述嗎?如何在WordPress新帖中設置分類

在WordPress主題中,我想要一些功能。當有人用「添加新帖子」功能添加帖子時,我想要默認類別。

我已經做了一個數據庫字段。 wp_user_cat是主鍵和鏈接wp_user_catwp_user table

的修改數據庫的條件: It is the modified database conditions.

所以,我做它增加了用戶的工作寄存器功能。我修改了wp_login.php,wp_create_user()wp_insert_user()函數users.php。 它是成功的,但我不知道在添加新帖子功能設置默認類別。

如果用戶的工作是音樂公司,當用戶點擊「添加新帖-按鈕」,它會自動設置音樂公司類別..

這是「添加新的」屏幕: It is the Add new Screen 此主題是aivahtheme中的MusicPlay主題。

請給我幫助..我需要知道文件名。我能行! (如果可能的話,給我說明。)

+0

好的,我明白了!抱歉! – user3483250

回答

0

如果我理解正確,你想限制發佈從user types只發布在某些類別,對吧?因此,類型A的用戶只能在類別A上發佈等等。

你可以先爲用戶創建角色:

function custom_roles() { 
    global $wp_roles; 
    add_role(
     'user_type_one', 
     __('User Type 1'), 
     array(
      'read'   => true, // true allows this capability 
      'edit_posts' => false, 
      'delete_posts' => false, // Use false to explicitly deny 
     ) 
    ); 
    add_role(
     'user_type_two', 
     __('User Type 2'), 
     array(
      'read'   => true, // true allows this capability 
      'edit_posts' => false, 
      'delete_posts' => false, // Use false to explicitly deny 
     ) 
    ); 
} 
add_action('after_setup_theme', 'custom_roles'); 

然後你使用插件來限制這些用戶類型類別: https://wordpress.org/plugins/restrict-categories/

注:我沒有在一個長期使用這種時間,但它應該工作或至少讓你在正確的軌道上。

+0

對!我想告訴它總結.. Peixotorms是天才! – user3483250

+0

嗨,peixotorms!我有任何問題!我對那個文件附加了什麼? – user3483250

相關問題