BuddyDev

Search

Private groups

Tagged: 

  • Participant
    ROBERT PADILHA on #39723

    Hello

    I’m with a private group where monthly subscription will be required to see the content posted on it.

    I would like to limit posts to the group administrator and its moderators.

    This way the subscribers would not be able to be publishing within the group and also not be able to share the content to the public part they will have on the site

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #39755

    Hello Robert,

    Thank you for posting. Please do let me know how are you managing subscriptions for private groups. Also, Are you looking for a way to restrict a particular user role or member type not able to post activity in that group?

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 1
    ROBERT JP on #39768

    Sorry for replying from another account because you are not able to access the previous one

    I have made the group private and am using paid memberships pro to charge memberships and unlock member access within the private group

    However the subscribing members of the group have the freedom to be posting within the group

    I would like to limit private group posts to group administrators only.

    Therefore, the group’s subscribers can only view the content and make comments and could not publish within it.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #39771

    Hello Robert,

    Check the following code it will restrict non-admin users from posting content in the group.

    
    
    add_action( 'wp_ajax_post_update', function() {
    	$object  = isset( $_POST['object'] ) ? sanitize_key( $_POST['object'] ) : '';
    	$item_id = isset( $_POST['item_id'] ) ? absint( $_POST['item_id'] ) : '';
    
    	if ( bp_is_group() ) {
    		$item_id = bp_get_current_group_id();
    		$object  = 'group';
    	}
    
    	if ( 'group' != $object ) {
    		return;
    	}
    
    	if ( ! groups_is_user_admin( get_current_user_id(), $item_id ) ) {
    		wp_send_json_error(
    			array(
    				'message' => __( 'You are not allowed to post.', 'buddypress' ),
    			)
    		);
    	}
    }, 9 );
    
    

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved