1

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; } 

1 Answer 1

1

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; } 

Related:

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.