bbp_forum_post_type
Filters the post type used for BuddyPress forums, allowing customization of forum display.
add_filter( 'bbp_forum_post_type', $callback, 10, 1 );
Description
Filters the post type used for BuddyBoss forums. Developers can modify this to use a custom post type for forums, allowing for greater flexibility in how forum content is stored and managed within the BuddyBoss ecosystem.
Usage
add_filter( 'bbp_forum_post_type', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to filter the 'bbp_forum_post_type' hook.
*
* This filter allows you to change the post type used for forums in bbPress.
* For instance, if you have a custom post type that you want to use as forums,
* you can register it and then filter this hook to point to your custom post type.
*
* In this example, we'll demonstrate adding a hypothetical custom post type
* named 'custom_bbpress_forum' to the list of allowed forum post types.
*
* @param string $post_type The current post type for forums.
* @return string The modified post type for forums.
*/
function my_custom_bbp_forum_post_type( $post_type ) {
// Check if a custom forum post type is defined and registered.
// In a real-world scenario, you would ensure 'custom_bbpress_forum'
// is actually registered using register_post_type().
$custom_forum_post_type = 'custom_bbpress_forum';
// You might want to add conditional logic here to determine when to use
// your custom post type, perhaps based on user roles or specific settings.
// For this example, we'll simply return our custom post type.
if ( post_type_exists( $custom_forum_post_type ) ) {
return $custom_forum_post_type;
}
// If the custom post type doesn't exist or isn't intended to be used,
// fall back to the default 'forum' post type.
return $post_type;
}
add_filter( 'bbp_forum_post_type', 'my_custom_bbp_forum_post_type', 10, 1 );
// Example of how you might register a custom post type for bbPress forums:
/*
function register_my_custom_bbp_forum_post_type() {
$labels = array(
'name' => _x( 'Custom Forums', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Custom Forum', 'Post Type Singular Name', 'text_domain' ),
// ... other labels
);
$args = array(
'label' => __( 'Custom Forums', 'text_domain' ),
'description' => __( 'Custom post type for bbPress forums', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'author', 'comments' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'rewrite' => array('slug' => 'custom-forums'),
'menu_icon' => 'dashicons-format-chat',
);
register_post_type( 'custom_bbpress_forum', $args );
}
add_action( 'init', 'register_my_custom_bbp_forum_post_type', 0 );
*/
?>
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/integrations/buddyboss/actions/bdb-postatopicreply.php:75
uncanny-automator-pro/src/integrations/bbpress/actions/bb-postatopicreply.php:74
uncanny-automator-pro/src/integrations/bbpress/triggers/bb-postareply.php:61
public function load_options() {
$bbp_forum_post_type = apply_filters( 'bbp_forum_post_type', 'forum' );
$args = array(
'post_type' => $bbp_forum_post_type,
'posts_per_page' => 99999, //phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
'orderby' => 'title',
'order' => 'ASC',
'post_status' => array( 'publish', 'private' ),
);
return Automator()->utilities->keep_order_of_options(
array(
'options_group' => array(
$this->action_meta => array(
Automator()->helpers->recipe->field->select_field_ajax(
$this->action_meta,
__( 'Forum', 'uncanny-automator-pro' ),
Automator()->helpers->recipe->options->wp_query( $args ),
'',
'',
false,
true,
array(
'target_field' => 'BDBTOPIC',
'endpoint' => 'select_topic_from_forum_BDBTOPICREPLY_NOANY',
)
),
Automator()->helpers->recipe->field->select_field( 'BDBTOPIC', __( 'Topic', 'uncanny-automator-pro' ), array(), false, false, false ),
Automator()->helpers->recipe->field->text_field( 'BDBREPLYCONTENT', esc_attr__( 'Reply content', 'uncanny-automator-pro' ), true, 'textarea' ),
),
),
)
);
}