Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 向WP中的注册添加角色_Wordpress_Registration_Buddypress_Role - Fatal编程技术网

Wordpress 向WP中的注册添加角色

Wordpress 向WP中的注册添加角色,wordpress,registration,buddypress,role,Wordpress,Registration,Buddypress,Role,我正在寻找一种方法来添加一个下拉列表,供用户在注册表中选择他们的角色(管理员除外)。 目前正在运行wordpress 4.7.4和buddypress 2.8.0,发现了一些代码片段,但没有一个真正起作用 非常感谢任何帮助您必须创建user-role.php文件并将其包含在functions.php文件中 <?php if( get_role('subscriber') ){ remove_role( 'subscriber' ); } if( get_role('client')

我正在寻找一种方法来添加一个下拉列表,供用户在注册表中选择他们的角色(管理员除外)。 目前正在运行wordpress 4.7.4和buddypress 2.8.0,发现了一些代码片段,但没有一个真正起作用


非常感谢任何帮助

您必须创建user-role.php文件并将其包含在functions.php文件中

<?php

if( get_role('subscriber') ){
  remove_role( 'subscriber' );
}
if( get_role('client') ){
  remove_role( 'client' );
}

// Add a Country (Others) role

$result = add_role( 'country', __(

'Country (Others)' ),

array(

'read' => true, // true allows this capability
'edit_posts' => true, // Allows user to edit their own posts
'edit_pages' => true, // Allows user to edit pages
'edit_others_posts' => true, // Allows user to edit others posts not just their own
'create_posts' => true, // Allows user to create new posts
'manage_categories' => true, // Allows user to manage post categories
'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
'edit_themes' => false, // false denies this capability. User can’t edit your theme
'install_plugins' => false, // User cant add new plugins
'update_plugin' => false, // User can’t update any plugins
'update_core' => false // user cant perform core updates

)

);

到目前为止,只找到了一个在更新的wp/bp版本上运行的已有一年历史的插件