Created
February 7, 2018 23:06
-
-
Save Wadizorg/25c6198e339d31435314a4e90ad0bc3c to your computer and use it in GitHub Desktop.
show_role_field
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 $myroles = array('photographer', 'general', 'makeup artist'); | |
echo"<select name='list_of_roles'>"; | |
foreach ($myroles as $myrole){ | |
echo "<option value='$myrole'>$myrole</option>"; | |
} | |
echo "</select>"; ?> | |
add_action(‘register_form’,’show_role_field’); | |
function show_role_field(){ ?> | |
<input id="role" type="hidden" tabindex="20" size="25" value= "” name=”role”/> | |
<?php | |
} | |
add_action('user_register', 'register_role'); | |
function register_role($user_id, $password="", $meta=array()) { | |
$userdata = array(); | |
$userdata['ID'] = $user_id; | |
$userdata['role'] = strtolower($_POST['role']); | |
wp_update_user($userdata); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment