• Resolved Georgio

    (@georgio-1)


    Hi @mrpritchett

    This code (from imath) has been working for a long time but now it doesn’t :

    function restrict_to_group_adminmods( $groups, $user_id ) {
        if ( empty( $groups ) || empty( $user_id ) ) {
            return $groups;
        }
    
        foreach ( $groups as $g => $group ) {
            if ( ! groups_is_user_admin( $user_id, $group->id ) && ! groups_is_user_mod( $user_id, $group->id ) ) {
                unset( $groups[ $g ] );
            }
        }
        return $groups;
    }
    add_filter( 'buddydrive_filter_select_user_group', 'restrict_to_group_adminmods', 10, 2 );

    This code restricts Buddydrive to group admins/mods. Any idea how to fix it?
    Thanks in advance.


    WP 4.7.2
    BP 2.7.4
    Buddydrive 2.0.0

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author mrpritchett

    (@mrpritchett)

    Hi Georgio,
    I’ll take a look, but this likely won’t work anymore as it does not look compatible with the latest versions.

    Plugin Author mrpritchett

    (@mrpritchett)

    This will not be compatible with 2.0 nor 2.1. Sorry.

    Hello @mrpritchett,
    but can’t you give us another compatible code to be able to restrict uploading capability to group admins/mods?
    Thanks…

    Plugin Author mrpritchett

    (@mrpritchett)

    @ssebech,
    Please contact me using the form at https://pritchett.media/contact/.

    Hello @mrpritchett,
    in the meantime I have tried to dig into the code a bit and found it:

    In the file … plugins/buddydrive/includes/buddydrive-functions.php – there is the function buddydrive_current_user_can( $capability = …
    And there on lines 993-994 I have made a hack:
    } elseif ( bp_is_group() ) {
    $can = (bool) groups_is_user_admin( $user_id, bp_get_current_group_id() ) || (bool) groups_is_user_mod( $user_id, bp_get_current_group_id() );
    }

    So now only group admins and mods can upload to any group’s BuddyDrive.
    But it would be nice to have it selectable in the plugin settings – per group – in the group manage area:
    1. Any members can upload to this group
    2. Only admins and mods can upload to this group

    Another hint: it would be useful that every upload or deletion would be posted in the group’s activity stream. Then with the help of the plugin “BuddyPress Group Email Subscription” users would receive email notifications.

    Regards,
    Stefan.

    Thread Starter Georgio

    (@georgio-1)

    And there on lines 993-994 I have made a hack: @ssebech Thank you very much

    But it would be nice to have it selectable in the plugin settings – per group – in the group manage area: @ssebech and @mrpritchett Very good idea

    Plugin Author mrpritchett

    (@mrpritchett)

    Until I have time to review the above code I do not recommend implementing this on any production environments.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Restrict to group admins/mods’ is closed to new replies.