5 Fix typo in function name
source | link
//create a hidden field for role
add_action('register_form','add_hidden_role_field');

function add_hidden_role_field(){
    if (isset($_GET['role'])){
        echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
    }
}

add_action('user_register', 'register_role''update_role');

//save the the role
function update_role($user_id, $password="", $meta=array()) {
   if (isset($_POST['role'])){
       $userdata = array();
       $userdata['ID'] = $user_id;
       $userdata['role'] = $_POST['role'];

       //only allow if user role is my_role to avoid a few new admins to the site
       if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
          wp_update_user($userdata);
       }
   }
}
//create a hidden field for role
add_action('register_form','add_hidden_role_field');

function add_hidden_role_field(){
    if (isset($_GET['role'])){
        echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
    }
}

add_action('user_register', 'register_role');

//save the the role
function update_role($user_id, $password="", $meta=array()) {
   if (isset($_POST['role'])){
       $userdata = array();
       $userdata['ID'] = $user_id;
       $userdata['role'] = $_POST['role'];

       //only allow if user role is my_role to avoid a few new admins to the site
       if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
          wp_update_user($userdata);
       }
   }
}
//create a hidden field for role
add_action('register_form','add_hidden_role_field');

function add_hidden_role_field(){
    if (isset($_GET['role'])){
        echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
    }
}

add_action('user_register', 'update_role');

//save the the role
function update_role($user_id, $password="", $meta=array()) {
   if (isset($_POST['role'])){
       $userdata = array();
       $userdata['ID'] = $user_id;
       $userdata['role'] = $_POST['role'];

       //only allow if user role is my_role to avoid a few new admins to the site
       if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
          wp_update_user($userdata);
       }
   }
}
4 Corrected 'register_role' to 'update_role'.
source | link
add_action('user_register', 'register_role''update_role');

//save the the role
function update_role($user_id, $password="", $meta=array()) {
   if (isset($_POST['role'])){
       $userdata = array();
       $userdata['ID'] = $user_id;
       $userdata['role'] = $_POST['role'];
        $user_type = $_POST['role'];
       //only allow if user role is my_role to avoid a few new admins to the site
        if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
            wp_update_user($userdata);
        }
        if (isset($user_type) && $user_type == "seller"){
            //save sellers fields
            update_user_meta($user_id, 'business_name', $_POST['business_name']);
            update_user_meta($user_id, 'business_address', $_POST['business_address']);
        }
        if (isset($user_type) && $user_type == "buyer"){
            //save sellers fields
            update_user_meta($user_id, 'buyer_name', $_POST['buyer_name']);
        }
   }
}
add_action('user_register', 'register_role');

//save the the role
function update_role($user_id, $password="", $meta=array()) {
   if (isset($_POST['role'])){
       $userdata = array();
       $userdata['ID'] = $user_id;
       $userdata['role'] = $_POST['role'];
        $user_type = $_POST['role'];
       //only allow if user role is my_role to avoid a few new admins to the site
        if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
            wp_update_user($userdata);
        }
        if (isset($user_type) && $user_type == "seller"){
            //save sellers fields
            update_user_meta($user_id, 'business_name', $_POST['business_name']);
            update_user_meta($user_id, 'business_address', $_POST['business_address']);
        }
        if (isset($user_type) && $user_type == "buyer"){
            //save sellers fields
            update_user_meta($user_id, 'buyer_name', $_POST['buyer_name']);
        }
   }
}
add_action('user_register', 'update_role');

//save the role
function update_role($user_id, $password="", $meta=array()) {
   if (isset($_POST['role'])){
       $userdata = array();
       $userdata['ID'] = $user_id;
       $userdata['role'] = $_POST['role'];
        $user_type = $_POST['role'];
       //only allow if user role is my_role to avoid a few new admins to the site
        if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
            wp_update_user($userdata);
        }
        if (isset($user_type) && $user_type == "seller"){
            //save sellers fields
            update_user_meta($user_id, 'business_name', $_POST['business_name']);
            update_user_meta($user_id, 'business_address', $_POST['business_address']);
        }
        if (isset($user_type) && $user_type == "buyer"){
            //save sellers fields
            update_user_meta($user_id, 'buyer_name', $_POST['buyer_name']);
        }
   }
}
3 Corrected 'filed' to 'field' and 'add_extra_role_fields' to 'add_hidden_role_field'.
source | link
//create a hidden filedfield for role
add_action('register_form','add_hidden_role_field');

function add_hidden_role_field(){
    if (isset($_GET['role'])){
        echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
    }
}

add_action('user_register', 'register_role');

//save the the role
function update_role($user_id, $password="", $meta=array()) {
   if (isset($_POST['role'])){
       $userdata = array();
       $userdata['ID'] = $user_id;
       $userdata['role'] = $_POST['role'];

       //only allow if user role is my_role to avoid a few new admins to the site
       if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
          wp_update_user($userdata);
       }
   }
}
//create a hidden field for role and extra fields needed
add_action('register_form','add_extra_role_fields''add_hidden_role_field');

function add_hidden_role_field(){
    if (isset($_GET['role'])){
        $user_type = $_GET['role'];
        echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
    }
    if (isset($user_type) && $user_type == "seller"){
        //add extra seller fields here eg:
        ?>
        business name:
        <input id="user_email" type="text" tabindex="20" size="25" value="" name="business_name"/>

        business address:
        <input id="user_email" type="text" tabindex="20" size="25" value="" name="business_address"/>
        <?php
    }
    if (isset($user_type) && $user_type == "buyer"){
        //add extra buyer fields here eg:
        ?>
        buyer name:
        <input id="user_email" type="text" tabindex="20" size="25" value="" name="buyer_name"/>
        <?php
    }
}
//create a hidden filed for role
add_action('register_form','add_hidden_role_field');

function add_hidden_role_field(){
    if (isset($_GET['role'])){
        echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
    }
}

add_action('user_register', 'register_role');

//save the the role
function update_role($user_id, $password="", $meta=array()) {
   if (isset($_POST['role'])){
       $userdata = array();
       $userdata['ID'] = $user_id;
       $userdata['role'] = $_POST['role'];

       //only allow if user role is my_role to avoid a few new admins to the site
       if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
          wp_update_user($userdata);
       }
   }
}
//create a hidden field for role and extra fields needed
add_action('register_form','add_extra_role_fields');

function add_hidden_role_field(){
    if (isset($_GET['role'])){
        $user_type = $_GET['role'];
        echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
    }
    if (isset($user_type) && $user_type == "seller"){
        //add extra seller fields here eg:
        ?>
        business name:
        <input id="user_email" type="text" tabindex="20" size="25" value="" name="business_name"/>

        business address:
        <input id="user_email" type="text" tabindex="20" size="25" value="" name="business_address"/>
        <?php
    }
    if (isset($user_type) && $user_type == "buyer"){
        //add extra buyer fields here eg:
        ?>
        buyer name:
        <input id="user_email" type="text" tabindex="20" size="25" value="" name="buyer_name"/>
        <?php
    }
}
//create a hidden field for role
add_action('register_form','add_hidden_role_field');

function add_hidden_role_field(){
    if (isset($_GET['role'])){
        echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
    }
}

add_action('user_register', 'register_role');

//save the the role
function update_role($user_id, $password="", $meta=array()) {
   if (isset($_POST['role'])){
       $userdata = array();
       $userdata['ID'] = $user_id;
       $userdata['role'] = $_POST['role'];

       //only allow if user role is my_role to avoid a few new admins to the site
       if (($userdata['role'] == "seller") or ($userdata['role'] == "buyer")){
          wp_update_user($userdata);
       }
   }
}
//create a hidden field for role and extra fields needed
add_action('register_form','add_hidden_role_field');

function add_hidden_role_field(){
    if (isset($_GET['role'])){
        $user_type = $_GET['role'];
        echo '<input id="user_email" type="hidden" tabindex="20" size="25" value="'.$_GET['role'].'" name="role"/>';
    }
    if (isset($user_type) && $user_type == "seller"){
        //add extra seller fields here eg:
        ?>
        business name:
        <input id="user_email" type="text" tabindex="20" size="25" value="" name="business_name"/>

        business address:
        <input id="user_email" type="text" tabindex="20" size="25" value="" name="business_address"/>
        <?php
    }
    if (isset($user_type) && $user_type == "buyer"){
        //add extra buyer fields here eg:
        ?>
        buyer name:
        <input id="user_email" type="text" tabindex="20" size="25" value="" name="buyer_name"/>
        <?php
    }
}
2 updated to comments update
source | link
1
source | link