Hi @alexius94,
You should track your user on those pages. For example, you can create a cookie with JavaScript, so you will know later which page was visited by the user.
Then, Nextend Social Login has a filter where you can modify the email and the username too.
$userData = array(
'email' => $email,
'username' => $sanitized_user_login
);
$userData = apply_filters('nsl_' . $this->getId() . '_register_user_data', $userData);
So your code would be for Facebook:
add_filter('nsl_facebook_register_user_data', function($userData){
if(isset($_COOKIE['page']) && $_COOKIE['page'] == 'A'){
// Note: username already contains the prefix here. So in this case, I replace fb_ with fba_
// username already validated. Make sure you do modify it to a valid username or do the username validaton here again.
$userData['username'] = preg_replace('/ˆfb_/', 'fba_', $userData['username']);
}
return $userData;
});
BTW:
I suggest you do not change the username based on the page. I think it would be better and simpler to set a user meta based on the source page. In that case, you should create the very same cookie as before. Then use the nsl_register_new_user action:
add_action('nsl_register_new_user', function($user_id){
if(isset($_COOKIE['page']) && $_COOKIE['page'] == 'A'){
update_user_meta( $user_id, 'page', 'A' );
}
});
Then you can add another plugin which allows you to filter by users by meta, for example: https://wordpress.org/plugins/amr-users/
Ps.: I have not tested the codes, but if you follow the logic, you should be fine.
-
This reply was modified 8 years, 2 months ago by
Nextendweb.