Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'code'

Viewing 25 results - 5,026 through 5,050 (of 32,481 total)
  • Author
    Search Results
  • #185742
    Robin W
    Moderator

    try doing the change that @tweichart suggested ie

    on line 1800 of the same file

    the error is still the same and it’s on line 1800. Fixing something on ln 1850 won’t do the trick here I guess, so you’d need to change as initially written ln 1796 from

    $post_stati = $posts_query->get( 'post_status' );
    to
    $post_stati = $posts_query->get( 'post_status' );
    if (!is_array($post_stati)){
        $post_stati = array($post_stati);
    }

    and then report back

    bobibrown0
    Participant

    Also comment the line 42, which is for when you have topics in the forum

    <?php //bbp_get_template_part( 'form', 'topic' ); ?>

    useStrict
    Participant

    I’m also using PHP 7.1. I fixed it by changing line 1800 to cast the value as an array.

    if ( empty( $post_stati ) ) {
                $post_stati = (array) bbp_get_public_status_id();
    #185712
    Tamas Rottenbacher
    Participant

    Hi,

    I created a custom shortcode for the site pages, posts.
    But it’s not working in forum post.

    How can i do?

    My custom shortcode code:

    function custom_shortcode_errorbox( $atts , $content ) {
    	// Attributes
    	$atts = shortcode_atts(
    		array(
    		),
    		$atts,
    		'error'
    	);	
    	$output = '<div class="errorbox"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> ' . $content . '</div>';
    	return $output;
    }
    add_shortcode( 'error', 'custom_shortcode_errorbox' );
    #185707
    Howdy_McGee
    Participant

    Ok, here’s what I did. If anyone has a better solution post it! What I was ultimately trying to do was combine both the WooCommerce accounts sidebar with the BBPress sidebar. I think the most difficult part / part I’m most unsure about is the bbp user ID which we’ll get to later.

    Unloading a Template

    I used the bbp_get_template_part filter to find and remove the user-details.php template from loading:

    /**
     * Prevent BBPress from loading certain templates
     *
     * @param Array $templates
     *
     * @return Array $templates;
     */
    function prefix_bbp_template_removal( $templates ) {
    
    	if( bbp_is_single_user() && is_array( $templates ) ) {
    		
    		
    		if( false !== ( $key = array_search( 'user-details.php', $templates ) ) ) {
    			unset( $templates[ $key ] );
    		}
    		
    	}
    	
    	return $templates;
    	
    }
    add_filter( 'bbp_get_template_part', 'prefix_bbp_template_removal');

    Loading a Template

    Then I used the bbp_locate_template() function to reload the template where I wanted it.

    bbp_locate_template( array( 'user-details.php' ), true, false );

    User Profile Links

    This is where it gets hairy. For whatever reason, when outside the “User Home”, BBPress doesn’t know which user is displaying so none of the sidebar links would link plus “Edit” and “Subscriptions” were missing. To show the last 2 links I needed to have bbp_is_user_home return true, in my case it was whenever the user was on WooCommerce Accounts pages:

    /**
     * Modify Home Conditional if viewing WooCommerce Account
     *
     * @return Boolean
     */
    function prefix_bbp_user_home( $is_user_home ) {
    	
    	if( function_exists( 'is_account_page' ) && is_account_page() ) {
    		$is_user_home = true;
    	}
    	
    	return $is_user_home;
    	
    }
    add_filter( 'bbp_is_user_home', 'prefix_bbp_user_home' );

    Which now shows the two links at the bottom. The final piece was actually getting the links to work correctly. This is what I’m most unsure about as I’m not sure how BBPress defines which user is displayed. I’m assuming there’s some kind of impersonation feature which makes this more difficult or something I’m not sure so I just return the current user ID:

    /** 
     * Give BBPress a User ID on Woocommerce Accounts
     *
     * @param Integer $bbp_user_id
     *
     * @return Integer $bbp_user_id
     */
    function prefix_bbp_user_id( $bbp_user_id ) {
    	
    	$user_id = get_current_user_id();
    	
    	if( function_exists( 'is_account_page' ) && is_account_page() && empty( $bbp_user_id ) ) {
    		$bbp_user_id = $user_id;
    	}
    	
    	return $bbp_user_id;
    		
    }
    add_filter( 'bbp_get_user_id', 'prefix_bbp_user_id' );

    I’d love to get some clarification on the BBPress user ID, why it doesn’t use the current user outside User Home, and what the best way to go about this is.

    #185700
    Howdy_McGee
    Participant

    So I found how I can go about loading a specific template, either bbp_get_template_part() or bbp_locate_template() should work.

    The only part of this question I’m not sure of is how to unload a specific template / stop it from loading initially. Any suggestions?

    bobibrown0
    Participant

    I’ve been searching for an answer, that I couldn’t find here. It was actually quite easy to find the solution by myself. But just in case someone need do to this too, this is how you do it:

    -> Create a new folder named “bbpress” at the root of your wordpress theme:
    /wp-content/themes/YOURTHEMENAME/bbpress/

    -> Find the file named “content-single-forum.php” located here:
    /wp-content/plugins/bbpress/templates/default/bbpress/content-single-forum.php
    and copy into your newly created folder:
    /wp-content/themes/YOURTHEMENAME/bbpress/content-single-forum.php

    Now bbpress will use this file instead, if your “YOURTHEMENAME” is in use.

    -> Open the file under
    /wp-content/themes/YOURTHEMENAME/bbpress/content-single-forum.php
    Go to line 48, and you should find this:
    <?php bbp_get_template_part( 'form', 'topic' ); ?>
    Comment this line this way:
    <?php //bbp_get_template_part( 'form', 'topic' ); ?>

    And you’re done! Easy and clean!

    Of course you might want to add a button to create a new topic.
    You can do it, following these steps:

    https://bbpress.org/forums/topic/how-to-add-new-topic-button/

    #185677
    Howdy_McGee
    Participant

    Is there a way to unhook the user-details.php and move re-call it in my own custom sidebar? Or is there a function to load the template part in my custom sidebar file?

    #185668
    tweichart
    Participant

    the error is still the same and it’s on line 1800. Fixing something on ln 1850 won’t do the trick here I guess, so you’d need to change as initially written ln 1796 from

    
    $post_stati = $posts_query->get( 'post_status' );
    

    to

    
    $post_stati = $posts_query->get( 'post_status' );
    if (!is_array($post_stati)){
        $post_stati = array($post_stati);
    }
    

    Setting $post_stati to an array through the second parameter of the get method call won’t help here as $post_stati is an empty string.

    #185664
    tweichart
    Participant

    ln 1851 looks like this:

    $meta_query = $posts_query->get( 'meta_query', array() );

    Robin W
    Moderator

    your filter reads

    add_filter( 'bbp_get_breadcrumb',mod_bbp_get_breadcrumb, 98, 2);

    it should read

    add_filter( 'bbp_get_breadcrumb','mod_bbp_get_breadcrumb', 98, 2);

    you need single quotes around the 2nd function

    pandraka
    Participant

    WordPress 4.8
    PHP 7
    bbpress 2.5.12
    buddypress 2.8.2

    I’m using group types on my bbpress/buddypress site. I’ve had to get creative when it comes to breadcrumbs. There was one minor changes to the bbp_get_breadcrumb function that I had to make to make the breadcrumbs work. I copied the function into my functions.php and added a filter. I’m getting an error/notice:
    Notice: Use of undefined constant mod_bbp_get_breadcrumb – assumed ‘mod_bbp_get_breadcrumb’

    The function is doing exactly what I want it to do. but this error is showing up. The functions is originally located in bbpress/includes/common/template.php file

    here’s the code:

    <?php
    function mod_bbp_get_breadcrumb( $args = array() ) {

    // Turn off breadcrumbs
    if ( apply_filters( ‘bbp_no_breadcrumb’, is_front_page() ) )
    return;

    // Define variables
    $front_id = $root_id = 0;
    $ancestors = $crumbs = $tag_data = array();
    $pre_root_text = $pre_front_text = $pre_current_text = ”;
    $pre_include_root = $pre_include_home = $pre_include_current = true;

    /** Home Text *********************************************************/

    // No custom home text
    if ( empty( $args[‘home_text’] ) ) {

    $front_id = get_option( ‘page_on_front’ );

    // Set home text to page title
    if ( !empty( $front_id ) ) {
    $pre_front_text = get_the_title( $front_id );

    // Default to ‘Home’
    } else {
    $pre_front_text = __( ‘Home’, ‘bbpress’ );
    }
    }

    /** Root Text *********************************************************/

    // No custom root text
    if ( empty( $args[‘root_text’] ) ) {
    $page = bbp_get_page_by_path( bbp_get_root_slug() );
    if ( !empty( $page ) ) {
    $root_id = $page->ID;
    }
    $pre_root_text = bbp_get_forum_archive_title();
    }

    /** Includes **********************************************************/

    // Root slug is also the front page
    if ( !empty( $front_id ) && ( $front_id === $root_id ) ) {
    $pre_include_root = false;
    }

    // Don’t show root if viewing forum archive
    if ( bbp_is_forum_archive() ) {
    $pre_include_root = false;
    }

    // Don’t show root if viewing page in place of forum archive
    if ( !empty( $root_id ) && ( ( is_single() || is_page() ) && ( $root_id === get_the_ID() ) ) ) {
    $pre_include_root = false;
    }

    /** Current Text ******************************************************/

    // Search page
    if ( bbp_is_search() ) {
    $pre_current_text = bbp_get_search_title();

    // Forum archive
    } elseif ( bbp_is_forum_archive() ) {
    $pre_current_text = bbp_get_forum_archive_title();

    // Topic archive
    } elseif ( bbp_is_topic_archive() ) {
    $pre_current_text = bbp_get_topic_archive_title();

    // View
    } elseif ( bbp_is_single_view() ) {
    $pre_current_text = bbp_get_view_title();

    // Single Forum
    } elseif ( bbp_is_single_forum() ) {
    $pre_current_text = bbp_get_forum_title();

    // Single Topic
    } elseif ( bbp_is_single_topic() ) {
    $pre_current_text = bbp_get_topic_title();

    // Single Topic
    } elseif ( bbp_is_single_reply() ) {
    $pre_current_text = bbp_get_reply_title();

    // Topic Tag (or theme compat topic tag)
    } elseif ( bbp_is_topic_tag() || ( get_query_var( ‘bbp_topic_tag’ ) && !bbp_is_topic_tag_edit() ) ) {

    // Always include the tag name
    $tag_data[] = bbp_get_topic_tag_name();

    // If capable, include a link to edit the tag
    if ( current_user_can( ‘manage_topic_tags’ ) ) {
    $tag_data[] = ‘‘ . esc_html__( ‘(Edit)’, ‘bbpress’ ) . ‘‘;
    }

    // Implode the results of the tag data
    $pre_current_text = sprintf( __( ‘Topic Tag: %s’, ‘bbpress’ ), implode( ‘ ‘, $tag_data ) );

    // Edit Topic Tag
    } elseif ( bbp_is_topic_tag_edit() ) {
    $pre_current_text = __( ‘Edit’, ‘bbpress’ );

    // Single
    } else {
    $pre_current_text = get_the_title();
    }

    /** Parse Args ********************************************************/

    // Parse args
    $r = bbp_parse_args( $args, array(

    // HTML
    ‘before’ => ‘<div class=”bbp-breadcrumb”><p>’,
    ‘after’ => ‘</p></div>’,

    // Separator
    ‘sep’ => is_rtl() ? __( ‘‹’, ‘bbpress’ ) : __( ‘›’, ‘bbpress’ ),
    ‘pad_sep’ => 1,
    ‘sep_before’ => ‘<span class=”bbp-breadcrumb-sep”>’,
    ‘sep_after’ => ‘</span>’,

    // Crumbs
    ‘crumb_before’ => ”,
    ‘crumb_after’ => ”,

    // Home
    ‘include_home’ => $pre_include_home,
    ‘home_text’ => $pre_front_text,

    // Forum root
    ‘include_root’ => $pre_include_root,
    ‘root_text’ => $pre_root_text,

    // Current
    ‘include_current’ => $pre_include_current,
    ‘current_text’ => $pre_current_text,
    ‘current_before’ => ‘<span class=”bbp-breadcrumb-current”>’,
    ‘current_after’ => ‘</span>’,
    ), ‘get_breadcrumb’ );

    /** Ancestors *********************************************************/

    // Get post ancestors
    if ( is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit() ) {
    $ancestors = array_reverse( (array) get_post_ancestors( get_the_ID() ) );
    }

    // Do we want to include a link to home?
    if ( !empty( $r[‘include_home’] ) || empty( $r[‘home_text’] ) ) {
    $crumbs[] = ‘‘ . $r[‘home_text’] . ‘‘;
    }

    // Do we want to include a link to the forum root?
    if ( !empty( $r[‘include_root’] ) || empty( $r[‘root_text’] ) ) {

    // Page exists at root slug path, so use its permalink
    $page = bbp_get_page_by_path( bbp_get_root_slug() );
    if ( !empty( $page ) ) {
    $root_url = get_permalink( $page->ID );

    // Use the root slug
    } else {
    $root_url = get_post_type_archive_link( bbp_get_forum_post_type() );
    }

    // Add the breadcrumb
    $crumbs[] = ‘‘ . $r[‘root_text’] . ‘‘;
    }

    // Ancestors exist
    if ( !empty( $ancestors ) ) {

    // Loop through parents
    foreach ( (array) $ancestors as $parent_id ) {

    // Parents
    $parent = get_post( $parent_id );

    // Skip parent if empty or error
    if ( empty( $parent ) || is_wp_error( $parent ) )
    continue;

    // Switch through post_type to ensure correct filters are applied
    switch ( $parent->post_type ) {

    // Forum
    case bbp_get_forum_post_type() :
    // PAA – modified
    //echo ‘forum title’. bbp_get_forum_title( $parent->ID) ;
    $test_title = bbp_get_forum_title( $parent->ID) ;
    if ($test_title == ‘Group Forums’){
    $base_url = bp_get_root_domain();
    $crumbs[] = ‘Groups‘;}
    else
    {$crumbs[] = ‘ID ) ) . ‘” class=”bbp-breadcrumb-forum”>’ . bbp_get_forum_title( $parent->ID ) . ‘‘; };

    break;

    // Topic
    case bbp_get_topic_post_type() :
    $crumbs[] = ‘ID ) ) . ‘” class=”bbp-breadcrumb-topic”>’ . bbp_get_topic_title( $parent->ID ) . ‘‘;
    break;

    // Reply (Note: not in most themes)
    case bbp_get_reply_post_type() :
    $crumbs[] = ‘ID ) ) . ‘” class=”bbp-breadcrumb-reply”>’ . bbp_get_reply_title( $parent->ID ) . ‘‘;
    break;

    // WordPress Post/Page/Other
    default :
    $crumbs[] = ‘ID ) ) . ‘” class=”bbp-breadcrumb-item”>’ . get_the_title( $parent->ID ) . ‘‘;
    break;
    }
    }

    // Edit topic tag
    } elseif ( bbp_is_topic_tag_edit() ) {
    $crumbs[] = ‘‘ . sprintf( __( ‘Topic Tag: %s’, ‘bbpress’ ), bbp_get_topic_tag_name() ) . ‘‘;

    // Search
    } elseif ( bbp_is_search() && bbp_get_search_terms() ) {
    $crumbs[] = ‘‘ . esc_html__( ‘Search’, ‘bbpress’ ) . ‘‘;
    }

    /** Current ***********************************************************/

    // Add current page to breadcrumb
    if ( !empty( $r[‘include_current’] ) || empty( $r[‘current_text’] ) ) {
    $crumbs[] = $r[‘current_before’] . $r[‘current_text’] . $r[‘current_after’];
    }

    /** Separator *********************************************************/

    // Wrap the separator in before/after before padding and filter
    if ( ! empty( $r[‘sep’] ) ) {
    $sep = $r[‘sep_before’] . $r[‘sep’] . $r[‘sep_after’];
    }

    // Pad the separator
    if ( !empty( $r[‘pad_sep’] ) ) {
    if ( function_exists( ‘mb_strlen’ ) ) {
    $sep = str_pad( $sep, mb_strlen( $sep ) + ( (int) $r[‘pad_sep’] * 2 ), ‘ ‘, STR_PAD_BOTH );
    } else {
    $sep = str_pad( $sep, strlen( $sep ) + ( (int) $r[‘pad_sep’] * 2 ), ‘ ‘, STR_PAD_BOTH );
    }
    }

    /** Finish Up *********************************************************/

    // Filter the separator and breadcrumb
    $sep = apply_filters( ‘bbp_breadcrumb_separator’, $sep );
    $crumbs = apply_filters( ‘bbp_breadcrumbs’, $crumbs );

    // Build the trail
    $trail = !empty( $crumbs ) ? ( $r[‘before’] . $r[‘crumb_before’] . implode( $sep . $r[‘crumb_after’] . $r[‘crumb_before’] , $crumbs ) . $r[‘crumb_after’] . $r[‘after’] ) : ”;

    return apply_filters( ‘mod_bbp_get_breadcrumb’, $trail, $crumbs, $r );
    }

    add_filter( ‘bbp_get_breadcrumb’,mod_bbp_get_breadcrumb, 98, 2);
    ?>

    At this point I’m not sure what else to do or if it’s ok to ignore the warning

    #185624

    In reply to: Members only forum

    u_Oi
    Participant

    Hi @dropshot

    You are looking for this code, paste it in functions.php

    //Restrict Topic Content and Replies for No-Registered Users
    function pj_hla_logged_in_topics($have_posts){
    if (!is_user_logged_in()){
    $have_posts = null;
    }
    return $have_posts;
    }
    add_filter('bbp_has_replies', 'pj_hla_logged_in_topics');

    Regards,

    #185618
    Robin W
    Moderator

    ok, a new page in a default theme has this

    <div class="entry-content">
    <div id="bbpress-forums">
    

    your page has this

    <div class="entry-content">
    <div style="clear: both"></div>
    <div class="the_champ_sharing_container the_champ_horizontal_sharing" super-socializer-data-href="https://www.lifeleap.org/community/">
    <div class="the_champ_sharing_title" style="font-weight:bold">Share:</div>
    <ul class="the_champ_sharing_ul">
    <li class="theChampSharingRound">
    <li class="theChampSharingRound">
    <li class="theChampSharingRound">
    <li class="theChampSharingRound">
    <li class="theChampSharingRound">
    </ul>
    <div style="clear:both"></div>
    </div>
    <div style="clear: both"></div>
    <p>
    <br>
    </p>
    <div id="bbpress-forums">

    Don’t think it’s bbpress

    #185599
    andrew55
    Participant

    This is exactly what we need. But when I use this function…

    //This function changes the text wherever it is quoted
    function change_translate_text( $translated_text ) {
    	if ( $translated_text == 'Subscriber' ) {
    	$translated_text = 'Member';
    	}
    	return $translated_text;
    }
    add_filter( 'gettext', 'change_translate_text', 20 );

    …it doesn’t change “Subscriber” to “Member” in profile area or anywhere else.

    Any suggestions on what I can do to get this working?

    Thanks for any help.

    #185591
    daileycon
    Participant

    I DID IT!!!! Now this adds an edit profile link in my top bar menu only if someone is logged in! Whooo hooo

    add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
    function your_custom_menu_item ($menu , $args ) {
        if (is_user_logged_in() && $args->theme_location == 'topbar_navigation') {
            $current_user = wp_get_current_user();
            $user=$current_user->user_nicename ;
            $profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';
            $menu = $menu . $profilelink;
        }
        return $menu;
    }
    #185590
    daileycon
    Participant

    Ok I found my menu slugs in my functions file.

    // Add Custom Primary Navigation
    function minti_register_custom_menu() {
    	register_nav_menu('main_navigation', 'Main Navigation');
    	register_nav_menu('footer_navigation', 'Footer Navigation');
    	register_nav_menu('topbar_navigation', 'Topbar Navigation');
    }

    but I still get that error when changing primary to topbar_navigation

    // Filter wp_nav_menu() to add profile link
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
    function my_nav_menu_profile_link($menu , $args) {
        if (is_user_logged_in() && $args->theme_location == 'topbar_navigation')
            return $menu;
        else
            $current_user = wp_get_current_user();
            $user=$current_user->user_nicename ;
            $profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';
            $menu = $menu . $profilelink;
            return $menu;
    }
    #185588
    daileycon
    Participant

    That code gives me this error in all 3 menus. I just want Edit Profile in the top menu.

    Warning: Missing argument 2 for my_nav_menu_profile_link(), called in /home/wp_5fnr6w/my site/wp-includes/class-wp-hook.php on line 300 and defined in /home/wp_5fnr6w/my site/wp-content/themes/unicon/functions.php on line 749

    If I remove “&& $args->theme_location == ‘primary'” and ” , $args”

    The error goes away but I have Edit Profile in all three menus.

    #185585
    Robin W
    Moderator

    ok, this is untested for functionality, but doesn’t error

    add_filter( 'bbp_get_topic_subscribers', 'rew_filter_subscrbers' );
    add_filter( 'bbp_get_forum_subscribers', 'rew_filter_subscrbers' );
    
    function rew_filter_subscribers ($users) {
    	$role = 'my_custom_role' ;
    	$filtered_ids = array();
    	foreach ( (array) $users as $user_id ) {
    		$user_info = get_userdata($user_id);
    		$user_roles = $user_info->roles ;
    		if (!in_array ($role, $user_roles)) {
    			array_push($filtered_IDs, $user_id);
    		}
    	
    	}
    return $filtered_ids ;
    }

    Do you know how to put this in to your child theme’s functions file?

    If so you will need to change my_custom_role in this line

    $role = 'my_custom_role' ;

    to the role name that you are using

    If you don’t know how to use functions file, then come back

    #185575
    Robin W
    Moderator

    probably this should work

    // Filter wp_nav_menu() to add profile link
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
    
    function my_nav_menu_profile_link($menu , $args) {
        if (is_user_logged_in() && $args->theme_location == 'primary') {
            $current_user = wp_get_current_user();
            $user=$current_user->user_nicename ;
            $profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';
            $menu = $menu . $profilelink;
        }
    	return $menu;
      
    }
    #185572
    daileycon
    Participant

    I’m using the following code to add an edit profile link in the menu. But it adds it to All menus, I have a top, main and footer menu. I just want it added to the top menu. Any help?

    // Filter wp_nav_menu() to add profile link
    add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
    function my_nav_menu_profile_link($menu , $args) {
        if (is_user_logged_in() && $args->theme_location == 'primary')
            return $menu;
        else
            $current_user = wp_get_current_user();
            $user=$current_user->user_nicename ;
            $profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';
            $menu = $menu . $profilelink;
            return $menu;
      
    }
    #185559
    Robin W
    Moderator

    not exactly sure what you are after, but try this code and play with it

    put this in your functions file – you don’t need to alter any templates

    add_action ('bbp_theme_after_reply_author_details', 'rew_display');
    add_action ('bbp_theme_after_topic_author_details', 'rew_display'); 
    
    //main function to display
    function rew_display () {
    	global $reply_id ;
    	$author_id=bbp_get_reply_author_id( $reply_id ) ;
    	$user = Am_Lite::getInstance()->getUser(); 
    	$some_match = Am_Lite::getInstance()->haveSubscriptions(364))
    	if ($author == $user && $some_match == "hello" ) {
    		echo '<div class = "rew_display">' ;
    			echo '<ul>' ;	
    				echo '<li>' ;
    					echo "I've donated" ;
    				echo '</li>' ;
    			echo '</ul>' ;
    		echo '</div>' ;
    	}
    }

    Come back if I can help clarify

    #185536
    andrew55
    Participant

    OK, forget my additional code. Can someone please let me know what snippet (just for bbBress) to show something only in the profile area of the reply author, only if it applies to them.

    In other words: “show if it applies to this specific reply author.”

    I’ve edited loop-single-reply.php with great results for similar features.

    Thanks for any suggestions.

    #185503
    Alex Stine
    Participant

    Looking back on it now, I never did have the development time to make this work before I discontinued CloudSearch, but this looks to be the best code if anyone’s brave enough to try it in the future. 🙂

    function exclude_topics_in_private_forum() {
    $forum_id = bbp_get_forum_id();
    $query = bbp_get_all_child_ids($forum_id, 'post');
    foreach($query as $key => $q) {
    if(is_private_forum($forum_id) ) {
    update_post_meta($key, 'exclude', 1);
    } elseif(!is_private_forum($forum_id) ) {
    delete_post_meta($q, 'exclude');
    }
    }
    }
    add_action('bbp_new_forum', 'exclude_topics_in_private_forum' );
    add_action('bbp_edit_forum', 'exclude_topics_in_private_forum' );

    Thanks for the help.

    #185502
    Alex Stine
    Participant

    Hello,

    I started to work on the code and then got my bill. That’s when I instantly stopped using CloudSearch. It’s a good starting place though. If I ever revisit CloudSearch in the future, I’m coming back for the code.

    Thanks for the help.

Viewing 25 results - 5,026 through 5,050 (of 32,481 total)
Skip to toolbar