I needed to restrict participant topic creation to selected forums but allow replies to all topics in all forums. I came up with this solution
function my_bbp_restrict_topic_creation( $can ) {
$forum_id = array(18,22,56); //change your forum id
if ( ! bbp_is_user_keymaster() && bbp_is_single_forum() && !in_array( bbp_get_forum_id(),$forum_id) ) {
$can = false;
}
return $can;
}
add_filter( 'bbp_current_user_can_publish_topics', 'my_bbp_restrict_topic_creation' );
Participants can only create topics in the three forums with IDs 18,22,and 56. Whereas the KeyMaster can create topics in all forums.
I did a code search and found this function in includes/common/functions line 1507 which seems a highly likely candidate.
function bbp_logout_url( $url = '', $redirect_to = '' ) {
// If there is no redirect in the URL, let's add one...
if ( ! strstr( $url, 'redirect_to' ) ) {
// Get the forum root, to maybe use as a default
$forum_root = bbp_get_root_url();
// No redirect passed, so check referer and fallback to request uri
if ( empty( $redirect_to ) ) {
// Check for a valid referer
$redirect_to = wp_get_referer();
// Fallback to request uri if invalid referer
if ( false === $redirect_to ) {
$redirect_to = bbp_get_url_scheme() . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
}
// Filter the $redirect_to destination
$filtered = apply_filters( 'bbp_logout_url_redirect_to', $redirect_to );
// Validate $redirect_to, default to root
$validated = wp_validate_redirect( $filtered, $forum_root );
// Assemble $redirect_to and add it (encoded) to full $url
$appended = add_query_arg( array( 'loggedout' => 'true' ), $validated );
$encoded = urlencode( $appended );
$url = add_query_arg( array( 'redirect_to' => $encoded ), $url );
}
// Filter & return
return apply_filters( 'bbp_logout_url', $url, $redirect_to );
}
so maybe filtering on ‘bbp_logout_url’ would work.
Let me know if you need further help
I have two websites running custom php to create Log In/Log Out entries on the menu.
The Log Out behavior is different on the two websites. I finally tracked down the problem to bbPress. The URL created by my custom code with w_logout_url() on the bbPress site includes:
&redirect_to=…
where the URL created by the site without bbPress installed does not.
Disabling bbPpress removes the &redirect_to=… and reenabling bbPress makes the redirect_to return.
That leads me to believe bbPress is changing /setting this value somewhere, but I don’t see any choice to change that value in the bbPress settings?
add_filter( 'wp_nav_menu_items', 'ccc_add_loginout_link', 10, 2 );
function ccc_add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'header-menu') {
$items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
}
elseif (!is_user_logged_in() && $args->theme_location == 'header-menu') {
$items .= '<li><a href="'. site_url('wpflogin') .'">Log In</a></li>';
}
return $items;
}
Thanks!!
can you list your plugins please- the original error
Line 1: <div class="error"> <p>This Plugin needs BBpress to work, pls. install it first and activate.</p></div>
is not from bbpress
Yes I get that, and I see my settings are configured to automatically now give this status to new additions, and supposedly the ability to post, but ‘half’ of those that already have the status cannot.
It’s a real shame that there are no codes written into the error messages.
I guess my two questions are (in the context of my above post)
- When did all my historically inactive users get all their statuses changed to participants, it could only be with a recent BBpress plugin update?
- Is there another encoded condition that has to be satisfied aside from “if user = Participant then validate post or reply?”.
I know an invalid or heavy file may stop posting, but I have increased the values of the attachments so this is out. Failed posters have however not always been uploading anything more than their text.
Anyway I should stop speculating and see when the successful and failed posters were entered into the system.
<!-- nextpage-> converts to paginated links when using wp_link_pages() WordPress function for pages, posts, etc content, some themes add it some may not. As stated on WordPress wp_link_pages() must be in a loop/used for post content output.
I don’t think(maybe wrong) that it would be a good idea to use it in topics and replies for bbpress since bbpress has it’s own pagination functionality.
Thought I’d mention it. 🙂
hmm..not come across this before, from googling seems to be a wrodpress.com thing – doesn’t mean that I’m right – there’s tons on the internet that I don’t know, but just tried <!-- nextpage-> on posts in a couple of test sites, and it does nothing.
Can only suggest you find out what is adding it, but you may need to accept that it doesn’t work in bbpress
Eh, I’ve thought that that code is built in into WP. If that is not the case, then it must come with some of the bundles that accompany my theme. Could it be Kirki Customizer Framework?
I tried to fix some typos, but it seems that it was interpreted as breach. Let me try anew.
Steps to reproduce.
1. Have the lorem ipsum text with <!--nextpage-->
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<!–nextpage–>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<
2. If I create a page in my site with that text (and only that text), I see the first part and the navigation to the second part as my theme defines. The navigation works i.e. by clicking I can go to the second part.
3. If I create a topic in my bbPress forum with that text (and only that text), I see the first part and the navigation to the second part as my theme defines. However the navigation does not work, i.e. by clicking I get the “too many redirects” error.
I got it working without needing to modify the code. Use Single – “Any Child Of” – form name.
Hello!
I don’t know whether my site has had this from the beginning or not, since I haven’t used <!-- nextpage-> before, but…
Paging works on normal pages (post_type=page), but on forums paging causes the “too many redirects” error (even with a post with just text, no links, no images).
My site has a DV certificate from the web host provider (they took care of everything), Settings → General has the same https address for WP and the site.
WP 5.4 and bbPress 2.6.4
ok, this could take some debugging !
firstly in dashboard>replies how many replies do you have?
can you copy the
All (1,090) | Mine (129) | Published (1,089) | Pending (1) | Bin (1) | Spam (2)
answer into this thread
Hi @robin-w
RThanks for your latest bbp updates. I have activated your new bug fix check box and removed my code from functions.php and I can still split topics. Woo hoo!
hey robin .. nice to see you man. in past weeks i went through lot of bbprees forum topics & found your comments so useful. Even above code that i shared is suggested by you only years ago. Thanks a lot again. it worked like a charm. God bless man.
try changing the argument line
if (($args['context'] == 'reply' || $args['context'] == 'topic') && $post_content == '') $output....etc.
Here it is :
<?php
/**
* Statistics Content Part
*
* @package bbPress
* @subpackage Theme
*/
// @codingStandardsIgnoreFile
// Allow plugin text domain in theme.
// Get the statistics.
$stats = bbp_get_statistics(); ?>
<?php do_action( 'bbp_before_statistics' ); ?>
<div class="widget_display_stats">
<div class="row stats_list">
<div class="col-12 stats_list_item mb-2">
<div class="bg-black-faded rounded-card p-2 h-100">
<div class="row align-items-center">
<div class="col-auto text-center d-flex pr-0 align-items-center justify-content-center">
<i class="cera-icon cera-users text-primary fa-2x p-3 card"></i>
</div>
<div class="col">
<h3 class="mb-0"><?php echo esc_html( $stats['user_count'] ); ?></h3>
<h5 class="text-muted text-uppercase small font-weight-bold mb-0"><?php esc_html_e( 'Registered Users', 'bbpress' ); ?></h5>
</div>
</div>
</div>
</div>
<div class="col-12 stats_list_item mb-2">
<div class="bg-black-faded rounded-card p-2 h-100">
<div class="row align-items-center">
<div class="col-auto text-center d-flex pr-0 align-items-center justify-content-center">
<i class="cera-icon cera-message-square text-primary fa-2x p-3 card"></i>
</div>
<div class="col">
<h3 class="mb-0"><?php echo esc_html( $stats['forum_count'] ); ?></h3>
<h5 class="text-muted text-uppercase small font-weight-bold mb-0"><?php esc_html_e( 'Forums', 'bbpress' ); ?></h5>
</div>
</div>
</div>
</div>
<div class="col-12 stats_list_item mb-2">
<div class="bg-black-faded rounded-card p-2 h-100">
<div class="row align-items-center">
<div class="col-auto text-center d-flex pr-0 align-items-center justify-content-center">
<i class="cera-icon cera-alert-circle text-primary fa-2x p-3 card"></i>
</div>
<div class="col">
<h3 class="mb-0"><?php echo esc_html( $stats['topic_count'] ); ?></h3>
<h5 class="text-muted text-uppercase small font-weight-bold mb-0"><?php esc_html_e( 'Topics', 'bbpress' ); ?></h5>
</div>
</div>
</div>
</div>
<div class="col-12 stats_list_item mb-2">
<div class="bg-black-faded rounded-card p-2 h-100">
<div class="row align-items-center">
<div class="col-auto text-center d-flex pr-0 align-items-center justify-content-center">
<i class="cera-icon cera-radio text-primary fa-2x p-3 card"></i>
</div>
<div class="col">
<h3 class="mb-0"><?php echo esc_html( $stats['reply_count'] ); ?></h3>
<h5 class="text-muted text-uppercase small font-weight-bold mb-0"><?php esc_html_e( 'Replies', 'bbpress' ); ?></h5>
</div>
</div>
</div>
</div>
</div>
</div><!-- .widget_display_stats -->
<?php do_action( 'bbp_after_statistics' ); ?>
<?php unset( $stats );
Hello,
after about 3 years of using bbPress without any issues, we have an issue with the index page – the standard one that is specified in settings -> forum is not working. There is just the header and the footer displayed from the theme, no content at all.
When I create a new page using the shortcode [bbp-forum-index], it is working fine. And all the threads and posts as well, they work fine on the original URLs. So it is really just the index page.
I haven’t done any changes in the forum in the last year or even more.
It is password protected, happy to share the password via a direct message.
Thanks,
Jan
Hi, if someone could assist I would appreciate it.
I have a new bbPress install here: https://classthink.com/forums/forum/microsoft/
I’ve created a new page with the [bbp-forum-index] shortcode here: https://classthink.com/forums/
But when I visit https://classthink.com/forums/ all I get is the Forums Archive.
It’s my — possibly incorrect — understanding that if you create a page with the same address as the forum slug, it should redirect to the page (in this case the forum index) rather than the archive.
Can someone please point me in the right direction?
Thanks,
Hello all,
I have been running BBpress for more than three of years, but started getting feedback that ‘Participants’ could no longer post or reply a month ago.
The user error message gives me no clue as to what’s behind the issue ‘ERROR your reply/post cannot be created’, and there’s nothing in the settings that gives a clue either.
I paid up to get ‘Pro tools’ to contribute something financially to the developer pot, but found no new clues in the tools either.
So this morning I thought I would chance a deactivation of the plugin and reinstall.
The moment I pressed deactivate, I got the message in the title of the post. My entire site is out of action – nothing public except the error message in the title. I can’t access the wp-admin only the FTP, but what to do? My site is out completely.
I believe I am up to date on all WP software (as flagged by the WP admin zone)… and anyway, I cannot offer any other info now.
The source code behind the message says:
Line 1: <div class="error"> <p>This Plugin needs BBpress to work, pls. install it first and activate.</p></div>
Please help. It’s my busy time of the year.
http://www.abeillessauvages.com
Hello, sorry first of all I am not a full on developer so forgive any basic questions, I have only just considered using bbpress for a forum I want to setup, I am familiar with WordPress and working with various plugins, can modify basic code etc when I need to, however it’s not my main job. I’ve installed bbpress and am looking at getting a theme to work well with it. Am willing to pay for a pro theme that is simple for users, nothing that special is required.
I just want to ask how hard is it as a fairly competent end user with some technical know how to set up a basic bbpress site, add a fairly functional user friendly theme, and get a forum up and running? It’s not wordpress.org, it might have max 100 users, closed/private forum.
I had assumed like most plugins bbpress would work fairly well “out of the box” and adding a template and maybe a few additional plugins to improve functionality would not be a big deal.
However I’ve just been quoted $2500 by a developer to do the above, to say my jaw hit the floor would be an understatement! Is bbpress THAT hard to implement that I need to pay mega bucks to get something simple up and running with it?? 🙁
PS the only reason I considered paying someone was to get it done in a few days rather than a few weeks as I have my main work to be getting on with as well… Otherwise I’d sit down and work through it step by step usually!
find
wp-content/plugins/bbpress/templates/default/bbpress/form-topic.php
FTP transfer this to your pc and edit
find starting from line 254
<?php if ( ! is_user_logged_in() ) : ?>
<?php bbp_get_template_part( 'form', 'user-login' ); ?>
<?php endif; ?>
and delete these lines
and save
create a directory on your theme called ‘bbpress’
ie wp-content/themes/%your-theme-name%/bbpress
where %your-theme-name% is the name of your theme
Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
wp-content/themes/%your-theme-name%/bbpress/form-topic.php
bbPress will now use this template instead of the original
So the issue with topic going into pending, is that the topic or reply most likely has invalid formatted code. Example: User type is a URL and hit submit, it is gone. Well, no, it is pending. because https://domain.com/something is not allowed. And the app does tell the user of the error.
So maybe long in coming, but just started working on a new bbpress BuddyPress forum.
Basically if a topic contains an invalid code such as a url (not and image url link), once submit it goes into draft mode. There maybe other reasons, but invalid code in topic is one.
I am currently working on a fix, short of making the tag available global. Biggest issue is link spamming.