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:
'role'=>get_option('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);
$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)) {
wp_die($this->Debug($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;
}
The plugin offers an entry point for this manipulation:
So, now it’s a matter of you filling up the fictional function in this example:
Related:
About Hooks and Filters
Actions and filters are NOT the same thingâ¦