Can't add users to groups
-
I am trying to have a site admin add users to groups. After adding action hook posted here: https://codex.buddypress.org/developer/how-to-add-members-to-a-group-via-wp-users-screen/ to my bp-custom.php I get the following error: Parse error: syntax error, unexpected T_FUNCTION in /home1/…/wp-content/plugins/bp-custom.php on line 18
I am running PHP 5.4.32, WP 4.0, BP 2.1
bp-custom.php code is included below:<?php
/**
* Disables BuddyPress’ registration process and fallsback to WordPress’ one.
*/
function add_users_to_bpgroup() {
if( bp_is_active(‘groups’) ):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 );
}
}
//form submission
add_action( ‘admin_footer’, function() { ?>
<script type=”text/javascript” charset=”utf-8″>
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(“Enter a Group ID”,”1″);
jQuery(“.wrap form”).append(‘<input type=”hidden” name=”bp_gid” value=”‘+gid+'” />’).submit();
}
});
</script>
<?php
});endif;
}
add_action ( ‘load-users.php’, ‘add_users_to_bpgroup’ );?>
- The topic ‘Can't add users to groups’ is closed to new replies.