Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Add Role To Register Link
- add_action('register_form', 'register_role_custom');
- function register_role_custom(){ ?>
- <input id="role" type="hidden" tabindex="0" size="0" value= "<?php if (isset($_GET['role'])){echo $_GET['role'];} ?>" name="role"/>
- <?php
- }
- add_action('user_register', 'custom_user_role');
- function custom_user_role($user_id, $password="", $meta=array()) {
- $userdata = array();
- $userdata['ID'] = $user_id;
- $userdata['role'] = $_POST['role'];
- if (($userdata['role'] == "employer") or ($userdata['role'] == "candidate")) {
- wp_update_user($userdata);
- }
- }
- //2. Add validation. In this case, we make sure first_name is required.
- add_filter('registration_errors', 'custom_registration_errors', 10, 3);
- function custom_registration_errors ($errors, $sanitized_user_login, $user_email) {
- if (empty( $_POST['role'])){
- $errors->add( 'no_role_error', __('<strong>ERROR</strong>: No Role Set in URL','mydomain') );
- return $errors;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement