Skip to:
Content
Pages
Categories
Search
Top
Bottom

Bulk assign a user to administer all groups (except 4)

  • Avatar of johnnymestizo
    johnnymestizo
    Participant

    @johnnymestizo

    Is this possible?

    Bulk assign a user to administer all groups (except 4)

    I want to have this person have admin rights to all groups (except 4), and all new groups created.

    Pretty much a forum moderator, but for group management.

    And no, I am not scrolling through 600+ groups manually.

    Is this possible?

    Cheers,

    Johnny

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    BP Group Management is not really meant to do this kind of thing. The easiest way to do it is with code, something like:

    `
    function bbg_promote_user_in_all_groups() {
    global $bp, $wpdb;

    if ( is_super_admin() ) {
    // user id of the member to promote
    $user_to_promote = 75;

    // IDs of the groups you want to skip
    $group_exceptions = array( 3, 12, 133, 832 );

    $all_groups = $wpdb->get_col( $wpdb->prepare( “SELECT id FROM {$bp->groups->table_name} ) );

    foreach( $all_groups as $group_id ) {
    if ( in_array( $group_id, $group_exceptions ) ) {
    continue;
    }

    $member = new BP_Groups_Member( $user_id, $group_id );
    $member->promote( ‘admin’ ); // also accepts ‘mod’
    }

    }
    }
    add_action( ‘admin_init’, ‘bbg_promote_user_in_all_groups’ );
    `

    This is untested and off the top of my head, but should pretty much work. (Test it by adding to a plugin file or bp-custom.php, then visiting the Dashboard as super admin. Make sure to comment out the add_action() line when done, so that it doesn’t run every Dashboard page load!) It’s possible that this function will time out on your live server, in which case you may have to introduce a little logic for only handling a smaller number of groups at a time, and then run it multiple times.

    Avatar of johnnymestizo
    johnnymestizo
    Participant

    @johnnymestizo

    Holy SH11233

    I ran the script above in bp-custom.php

    It white screened both the front end and the backend.

    I restarted linux.

    Still white screened.

    So I had to revert to a backup from a day ago.

    I have lost about 3 new groups, 3 new users, 2 market press orders.

    Oh well – casualty of war.

    U got any ideas on running a virtual buddy press + multisite at home… preferably my exact online site instance.

    Perhaps clone my site, virtually and run a parallel instance for testing purposes.

    Johnny

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.