Skip to content

Instantly share code, notes, and snippets.

@Wadizorg
Created February 7, 2018 23:06
Show Gist options
  • Save Wadizorg/25c6198e339d31435314a4e90ad0bc3c to your computer and use it in GitHub Desktop.
Save Wadizorg/25c6198e339d31435314a4e90ad0bc3c to your computer and use it in GitHub Desktop.
show_role_field
< ?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