admin管理员组文章数量:1323524
I need to get the content of a field in user meta role_type
, and replace the actual user role based on the user selection.
I use this function to replace the user role:
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
function myplugin_registration_save( $user_id )
{
$user = new WP_User( $user_id );
$user->remove_role( 'subscriber' ); // Optional, you don't have to remove this role if you want to keep subscriber as well
$user->add_role( $role_type );
}
I don't know how to get the usermeta value, and replace role_type
本文标签: phpfunction to assign user role based on a field from usermeta
版权声明:本文标题:php - function to assign user role based on a field from usermeta 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742133417a2422265.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论