Created
December 2, 2016 14:47
-
-
Save imath/97f98706dd42e58d6847a391c8f7f0c0 to your computer and use it in GitHub Desktop.
Temporary fix for https://wordpress.org/support/topic/commenting-bug-under-buddypress-groups-multisite/ so that users can wait for WP Idea Stream 2.3.4...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Temporary fix for: | |
* https://wordpress.org/support/topic/commenting-bug-under-buddypress-groups-multisite/ | |
* | |
* Will be part of WP Idea Stream 2.3.4 | |
*/ | |
// Exit if accessed directly. | |
defined( 'ABSPATH' ) || exit; | |
function tempfix_group_map_meta_caps( $caps = array(), $cap = '', $user_id = 0, $args = array() ) { | |
if ( 'read_idea' !== $cap || empty( $user_id ) ) { | |
return $caps; | |
} | |
if ( ! bp_is_group() ) { | |
$is_group_referer = 0 === strpos( wp_get_referer(), bp_get_groups_directory_permalink() ); | |
if ( ! $is_group_referer || empty( $_POST['comment_post_ID'] ) ) { | |
return $caps; | |
} | |
$idea_meta = get_post_meta( (int) $_POST['comment_post_ID'], '_ideastream_group_id', true ); | |
$group = groups_get_group( array( 'group_id' => $idea_meta ) ); | |
// It's not a group simply return the requested caps. | |
if ( ! is_a( $group, 'BP_GROUPS_GROUP' ) ) { | |
return $caps; | |
} | |
} else { | |
$group = groups_get_current_group(); | |
} | |
if ( groups_is_user_member( $user_id, $group->id ) ) { | |
$caps = array( 'exist' ); | |
} | |
return $caps; | |
} | |
add_filter( 'wp_idea_stream_map_meta_caps', 'tempfix_group_map_meta_caps', 11, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment