Created
October 23, 2015 12:58
-
-
Save vimes1984/19e571f1dc18a0afb399 to your computer and use it in GitHub Desktop.
Adding users to groups depending on dropdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * | |
| *hooking into buddypress's user sgin up to give users roles.. | |
| * | |
| */ | |
| add_action('bp_core_signup_user', 'custom_signup', 10, 5); | |
| public function custom_signup($user_id, $user_login, $user_password, $user_email, $usermeta){ | |
| $getchoice = $usermeta['accounttype']; | |
| switch ($getchoice){ | |
| case 'Buyer': | |
| groups_join_group( 2, $user_id ); | |
| wp_update_user( array( 'ID' => $user_id, 'role' => 'buyer' ) ); | |
| break; | |
| case 'Seller': | |
| wp_update_user( array( 'ID' => $user_id, 'role' => 'seller' ) ); | |
| $testdump = get_user_meta($user_id); | |
| groups_join_group( 1, $user_id ); | |
| break; | |
| case 'Consultants': | |
| wp_update_user( array( 'ID' => $user_id, 'role' => 'advisor' ) ); | |
| groups_join_group( 3, $user_id ); | |
| break; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment