Created
November 12, 2011 07:02
-
-
Save yassiryahya/1360173 to your computer and use it in GitHub Desktop.
Assigning Role On Wordpress Registration Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assigning Role On Wordpress Registration Page | |
Author: Yassir Yahya | |
Contributor: Rizal Almashoor | |
Article link: http://octalforty.com/articles/assigning-role-on-wordpress-registration-page/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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