bp_groups_exclude_forums_topics_by_group_type_args( $args_topic )
Exclude Forums topic from topic loop if any forum is attached to a group and that group have a group type and that group type is hidden from the directory page.
Description
Parameters
- $args_topic
-
(Required)
Return
(mixed) $args_topic
Source
File: bp-groups/bp-groups-filters.php
function bp_groups_exclude_forums_topics_by_group_type_args( $args_topic ) {
if ( bbp_is_forum_archive() || bbp_is_topic_archive() ) {
$exclude_topic_ids = array();
// Check group type enabled
if ( true === bp_disable_group_type_creation() ) {
// Get excluded group ids.
$exclude_group_ids = array_unique( bp_groups_get_excluded_group_ids_by_type() );
foreach ( $exclude_group_ids as $exclude_group_id ) {
// Get forums id by group id.
$exclude_forum_ids = bbp_get_group_forum_ids( $exclude_group_id );
// Loop forum ids to get topics
foreach ( $exclude_forum_ids as $exclude_forum_id ) {
$args = array(
'post_parent' => $exclude_forum_id,
'post_type' => bbp_get_topic_post_type(),
'numberposts' => - 1,
'fields' => 'ids',
);
// Get topics of forum.
$topics = get_children( $args );
foreach ( $topics as $exclude_topic_id ) {
// Set $exclude_topic_ids array.
$exclude_topic_ids[] = $exclude_topic_id;
}
}
}
}
if ( ! empty( $exclude_topic_ids ) ) {
$args_topic['post__not_in'] = $exclude_topic_ids;
}
}
return $args_topic;
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.1.9 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.