Created
January 6, 2024 16:56
-
-
Save cryptexvinci/2668f6a86db6394ec8c4f91e361eb634 to your computer and use it in GitHub Desktop.
Ultimate Member - Adds a user to a specified group
This file contains 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 | |
/* | |
* Adds a user to a specified group with specific details, such as the group ID, user ID, | |
* when a user registers on a website using the Ultimate Member plugin. | |
*/ | |
add_action( 'um_registration_set_extra_data', 'my_registration_set_extra_data', 10, 2 ); | |
function my_registration_set_extra_data( $user_id, $args ) { | |
global $wpdb; | |
$table_name = UM()->Groups()->setup()->db_groups_table; | |
$wpdb->insert( | |
$table_name, | |
array( | |
'group_id' => 'YOUR_GROUP_ID', | |
'user_id1' => $user_id, | |
'user_id2' => $user_id, | |
'status' => 'approved', | |
'role' => 'member', | |
'date_joined' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) | |
), | |
array( '%d', '%d', '%d', '%s', '%s', '%s' ) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment