diff --git a/includes/caps.php b/includes/caps.php index 2f62a9da..ff6ca4e2 100644 --- a/includes/caps.php +++ b/includes/caps.php @@ -90,6 +90,11 @@ function bp_docs_map_meta_caps( $caps, $cap, $user_id, $args ) { switch ( $doc_settings[ $cap_name ] ) { case 'anyone' : $caps[] = 'exist'; + + // Anonymous comment posting should respect site-wide setting. + if ( 'bp_docs_post_comments' == $cap_name && get_option( 'comment_registration' ) ) { + $caps = array(); + } break; case 'loggedin' : diff --git a/includes/functions.php b/includes/functions.php index a5245f8a..95faf65f 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -563,7 +563,10 @@ function bp_docs_get_access_options( $settings_field, $doc_id = 0, $group_id = 0 } // Allow anonymous reading - if ( in_array( $settings_field, array( 'read', 'read_comments', 'post_comments', 'view_history' ) ) ) { + if ( in_array( $settings_field, array( 'read', 'read_comments', 'view_history' ) ) + // Allow anonymous comment posting setting if site option allows it. + || ( 'post_comments' == $settings_field && ! get_option( 'comment_registration' ) ) + ) { $options[10] = array( 'name' => 'anyone', 'label' => __( 'Anyone', 'buddypress-docs' ),