Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save wbcomdev/0da93ebea1c1d9cbaff96b552a6feea1 to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/0da93ebea1c1d9cbaff96b552a6feea1 to your computer and use it in GitHub Desktop.
<?php
**
* Added to group automattic after succesfull user registration.
*
* @param string $user_id Get a user id.
*/
function wbcom_add_user_to_group_after_registration( $user_id ) {
if ( ! function_exists( 'groups_join_group' ) ) {
return;
}
/* Change the group id here. */
$group_ids = array( 12 );
foreach ( $group_ids as $group_id ) {
groups_join_group( $group_id, $user_id );
}
}
add_action( 'user_register', 'wbcom_add_user_to_group_after_registration' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment