Добавить роль к регистрации в WP

Я ищу способ добавить раскрывающийся список для пользователей в форме регистрации, чтобы выбрать свою роль (кроме администратора). В настоящее время работает wordpress 4.7.4 с buddypress 2.8.0., нашел несколько фрагментов и тому подобное, но ни один из них на самом деле не работает.

Любая помощь высоко ценится


person Nec    schedule 01.05.2017    source источник
comment
пока нашел только плагин годичной давности, который работает на более новых версиях wp/bp wordpress. org/plugins/wp-roles-at-registration   -  person Nec    schedule 01.05.2017


Ответы (1)


Вы должны создать файл 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

)

);
person Rakhi Prajapati    schedule 02.05.2017