Skip to content

Instantly share code, notes, and snippets.

@yassiryahya
Created November 12, 2011 07:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yassiryahya/1360173 to your computer and use it in GitHub Desktop.
Save yassiryahya/1360173 to your computer and use it in GitHub Desktop.
Assigning Role On Wordpress Registration Page
Assigning Role On Wordpress Registration Page
Author: Yassir Yahya
Contributor: Rizal Almashoor
Article link: http://octalforty.com/articles/assigning-role-on-wordpress-registration-page/
<?php
//
// Modify registration form to include roles
//
add_action('user_register', 'register_role');
function register_role($user_id, $password="", $meta=array()) {
$userdata = array();
$userdata['ID'] = $user_id;
$userdata['role'] = $_POST['cimy_uef_USERTYPE'];
if ($userdata['role'] == 'A Contributor') {
$userdata['role'] = 'contributor';
}
if ($userdata['role'] == 'An Editor') {
$userdata['role'] = 'editor';
}
//only allow if user role is my_role
if (($userdata['role'] == "contributor") or ($userdata['role'] == "editor")){
wp_update_user($userdata);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment