Last active
November 30, 2021 22:16
-
-
Save rohmann/6151699 to your computer and use it in GitHub Desktop.
Quick users page mod to allow for bulk adding to BuddyPress groups.
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 | |
add_action('load-users.php',function() { | |
if(isset($_GET['action']) && isset($_GET['bp_gid']) && isset($_GET['users'])) { | |
$group_id = $_GET['bp_gid']; | |
$users = $_GET['users']; | |
foreach ($users as $user_id) { | |
groups_join_group( $group_id, $user_id ); | |
} | |
} | |
//Add some Javascript to handle the form submission | |
add_action('admin_footer',function(){ ?> | |
<script> | |
jQuery("select[name='action']").append(jQuery('<option value="groupadd">Add to BP Group</option>')); | |
jQuery("#doaction").click(function(e){ | |
if(jQuery("select[name='action'] :selected").val()=="groupadd") { e.preventDefault(); | |
gid=prompt("Please enter a BuddyPres Group ID","1"); | |
jQuery(".wrap form").append('<input type="hidden" name="bp_gid" value="'+gid+'" />').submit(); | |
} | |
}); | |
</script> | |
<?php | |
}); | |
}); |
Thanks very much, Rohmann. Will check that out, and update here if I find anything.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm honestly not sure, sorry. I'd start by checking BuddyPress source for the
groups_join_group
function and see if anything has changed there.