Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Creating two separate registration for different roles is easy:
- //http://wordpress.stackexchange.com/questions/15954/separate-registration-and-login-for-different-roles
- //create a hidden filed for role
- add_action('register_form','add_hidden_role_field');
- function add_hidden_role_field(){
- if (isset($_GET['role'])){
- echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
- }
- }
- add_action('user_register', 'register_role');
- //save the the role
- function update_role($user_id, $password="", $meta=array()) {
- if (isset($_POST['role'])){
- $userdata = array();
- $userdata['ID'] = $user_id;
- $userdata['role'] = $_POST['role'];
- //only allow if user role is my_role to avoid a few new admins to the site
- if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
- wp_update_user($userdata);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment