WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to use the plugin Facebook-AWD plugin.

My site would provide two ways of registration (normal and register with Facebook). Users must select their role, ie: buyer and seller.

With normal registration, I can achieve this easily but if my users choose to register with Facebook-AWD they can't select between roles as the plugin is set up to register user with default role:


How can achieve this by adding a hook or action or filter to the plugin in order to preserve the plugin core for future update?

public function register_user()
    $username = sanitize_user($this->me['first_name'], true);
    $i = '';
    while (username_exists($username . $i)) {
        $i = absint($i);
    $username = $username . $i;
    $userdata = array(
        'user_pass' => wp_generate_password(), 
        'user_login' => $username, 
        'user_nicename' => $username, 
        'user_email' => $this->me['email'], 
        'display_name' => $this->me['name'], 
        'nickname' => $username, 
        'first_name' => $this->me['first_name'], 
        'last_name' => $this->me['last_name'], 
        'role' => get_option('default_role')
    $userdata = apply_filters('AWD_facebook_register_userdata', $userdata);
    $new_user = wp_insert_user($userdata);
    //Test the creation                         
    if (isset($new_user->errors)) {
    if (is_int($new_user)) {
        //send email new registration
        wp_new_user_notification($new_user, $userdata['user_pass']);
        return $new_user;

    return false;
share|improve this question
up vote 1 down vote accepted

The plugin offers an entry point for this manipulation:

$userdata = apply_filters('AWD_facebook_register_userdata', $userdata);

So, now it's a matter of you filling up the fictional function in this example:

add_filter( 'AWD_facebook_register_userdata', 'user_role_wpse_87863', 10, 1 );

function user_role_wpse_87863 ( $userdata )
    $userdata['role'] = your_way_of_getting_the_role();

    return $userdata;


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.