Robin W! Thanks so much! Your answers led me to the solution:
in functions.php , i have added(with add_filter) a modified “bbp_get_user_profile_url” function,which generates profile urls (original is in bbpress\includes\users\template.php):
here is my code:
remove_filter( 'bbp_get_user_profile_url', 'bbp_get_user_profile_url');
add_filter('bbp_get_user_profile_url','my_replaced' , 10 ,4);
function my_replaced ($url, $user_id, $user_nicename = '' ){
global $wp_rewrite;
if ( empty( $user_id ) ) {return false;}
$early_profile_url = apply_filters( 'bbp_pre_get_user_profile_url', (int) $user_id );
if ( is_string( $early_profile_url ) ) { return $early_profile_url; }
if ( $wp_rewrite->using_permalinks() ) { // if pretty permalinks
$url = $wp_rewrite->root . bbp_get_user_slug() . '/%' . bbp_get_user_rewrite_id() . '%';
if ( empty( $user_nicename ) ) { $user_nicename = bbp_get_user_nicename( $user_id );}
$url = str_replace( '%' . bbp_get_user_rewrite_id() . '%', $user_id, $url );
$url = home_url( user_trailingslashit( $url ) );
}
else { // Unpretty permalinks
$url = add_query_arg( array( bbp_get_user_rewrite_id() => $user_id ), home_url( '/' ) );
}
//return apply_filters( 'Replaced_bbp_get_user_profile_url', $url, $user_id, $user_nicename );
return $url;
}
Ok, I’ve had a think, and another look.
There is no easy way to do less than you’ve done.
The problem is that by the time the “apply filters” has been applied, the $output variable has already been created using the input variables, so changing $r is too late.
What this function needs is an earlier apply filters called say ‘bbp_list_forums_args’ for the $r variable, the you could add a simple filter along the lines of
function hide_forum_counts ($r) {
$r['show_topic_count'] = false ;
$r['show_reply_count'] = false ;
$r['separator'] = ' ';
return $r ;
}
add_filter('bbp_list_forums_args','hide_forum_counts') ;
I’ve have suggested this is a trac ticket
Thanks Stephen – I have added this list to the Codex step by step instructions, so I won’t forget it again !
Have you used the plugin bbP signature?
It is really up to the developers what they spend time on developing. They do this software in their spare time and for free.
If plugins are readily available, they’re seems little point in integrating them. A variety of plugins also gives user choice, and freedom for others to improve the code.
And you would be very unhappy be the sounds of it if they integrated some of the current plugins into core code.
So I repeat, if you don’t like the current plugins, then come back with a detailed critique of what they don’t do, and what they do wrong. That way the developers can see what could be better, and maybe then they would be fired up to add it into core.
So come back with which plugins and detailed issues and feature requests.
Sorry, totally misread this – thought you had posts mirroring and wasted to get rid of them.
I suspect that it would be very hard to get them to just replicate in the database, hits at core code.
But you could re-do your forum templates to show them twice.
Beyond my immediate knowledge, but start by looking at you forum page loop, and then the templates viz
wp-content/plugins/bbpress/templats/default/bbpress
@robin-w Thank you for helping me out with this. I can go right to the http://mysite.com/wp-login.php page without any hangup. I also tried creating a new page and used the [bbpress-login] shortcode with the login widget disabled. Still no luck. I removed any custom jquery from the theme, same result. I removed the widgetized area from the functions.php to be sure the sidebar wasn’t registering anything. Still going to a blank page.
The last thing I tried is disabling all of the plugins except bbPress switching to Twenty Fourteen Theme. going to the http://mysite.com/my-new-page-name and still getting the same result.
These are the plugins that are installed…
Akismet: Version 2.5.9
Contact Form 7: Version 3.7.1
The Events Calendar: Version 3.4.1
WP User Avatar: Version 1.7.2
Most bbp functions have simple variables. Yes, there must be a shorter way, but this is an array not a simple variable, and it builds an unordered list using the array and a loop.
It has an “apply filters” as part of the function, so they are expecting it to be able to be filtered, but hopefully not by having to do it all again !
I am writing some codex guide for filtering in bbPress, and by co0incidence was just using this oen as an example, and have been trying to crack it.
I can do it by amending the template –
https://codex.bbpress.org/layout-and-functionality-examples-you-can-use/ section 2, and save template into
wp-content/themes/yourthemename/bbpress
bbPress then uses that one.
I have posted a fresh query to Stephen Edgar or JJJ to pick up, but it’s gone into moderation as I posted a whole lot of code. Hopefully one of the two will pick it up and answer.
In the meantime yours is so far the best answer !
ok, so I know how to filter variables (and am documenting for the codex), but I cannto figure the syntax for an array.
As an example (and apologies for long code – but in this case hope you’ll let me off!)
function bbp_list_forums( $args = '' ) {
// Define used variables
$output = $sub_forums = $topic_count = $reply_count = $counts = '';
$i = 0;
$count = array();
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
'before' => '<ul class="bbp-forums-list">',
'after' => '</ul>',
'link_before' => '<li class="bbp-forum">',
'link_after' => '</li>',
'count_before' => ' (',
'count_after' => ')',
'count_sep' => ', ',
'separator' => ', ',
'forum_id' => '',
'show_topic_count' => true,
'show_reply_count' => true,
), 'list_forums' );
// Loop through forums and create a list
$sub_forums = bbp_forum_get_subforums( $r['forum_id'] );
if ( !empty( $sub_forums ) ) {
// Total count (for separator)
$total_subs = count( $sub_forums );
foreach ( $sub_forums as $sub_forum ) {
$i++; // Separator count
// Get forum details
$count = array();
$show_sep = $total_subs > $i ? $r['separator'] : '';
$permalink = bbp_get_forum_permalink( $sub_forum->ID );
$title = bbp_get_forum_title( $sub_forum->ID );
// Show topic count
if ( !empty( $r['show_topic_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
$count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID );
}
// Show reply count
if ( !empty( $r['show_reply_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
$count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID );
}
// Counts to show
if ( !empty( $count ) ) {
$counts = $r['count_before'] . implode( $r['count_sep'], $count ) . $r['count_after'];
}
// Build this sub forums link
$output .= $r['link_before'] . '<a href="' . esc_url( $permalink ) . '" class="bbp-forum-link">' . $title . $counts . '</a>' . $show_sep . $r['link_after'];
}
// Output the list
echo apply_filters( 'bbp_list_forums', $r['before'] . $output . $r['after'], $r );
}
}
If I wanted to turn off the topic and reply counts, I could use a filter which would look something like
function hide_forum_counts () {
$r['show_topic_count'] = false ;
$r['show_reply_count'] = false ;
$r['separator'] = ' ';
return $r ;
}
add_filter('bbp_list_forums','hide_forum_counts') ;
Stephen, JJJ or other bbp genius – can you post the answer, I have tried everything to prevent needing to copy all the original function, but have failed
Yes. So this is my code which works:
add_filter('bbp_list_forums','custom_bbp_list_forums',10);
function custom_bbp_list_forums( $args = '' ) {
// Define used variables
$output = $sub_forums = $topic_count = $reply_count = $counts = '';
$i = 0;
$count = array();
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
'before' => '<ul class="bbp-forums-list">',
'after' => '</ul>',
'link_before' => '',
'link_after' => '',
'count_before' => '<span>',
'count_after' => '</span>',
'count_sep' => '</span><span>',
'separator' => '',
'forum_id' => '',
'show_topic_count' => true,
'show_reply_count' => true,
), 'list_forums' );
// Loop through forums and create a list
$sub_forums = bbp_forum_get_subforums( $r['forum_id'] );
if ( !empty( $sub_forums ) ) {
// Total count (for separator)
$total_subs = count( $sub_forums );
foreach ( $sub_forums as $sub_forum ) {
$i++; // Separator count
// Get forum details
$count = array();
$show_sep = $total_subs > $i ? $r['separator'] : '';
$permalink = bbp_get_forum_permalink( $sub_forum->ID );
$title = bbp_get_forum_title( $sub_forum->ID );
// Show topic count
if ( !empty( $r['show_topic_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
$count['topic'] = bbp_get_forum_topic_count( $sub_forum->ID );
}
// Show reply count
if ( !empty( $r['show_reply_count'] ) && !bbp_is_forum_category( $sub_forum->ID ) ) {
$count['reply'] = bbp_get_forum_reply_count( $sub_forum->ID );
}
// Counts to show
if ( !empty( $count ) ) {
$counts = $r['count_before'] . implode( $r['count_sep'], $count ) . $r['count_after'];
}
}
// Output the list
echo apply_filters( 'bbp_list_forumss', $r['before'] . $output . $r['after'], $r );
}
}
but maybe there is an easier way to modify arguments array?!
bbPress actually goes looking for various templates to ‘wrap’ our templates in:
In this order:
– plugin-bbpress.php
– bbpress.php
– forums.php
– forum.php
– generic.php
– page.php
– single.php
– index.php
bbPress will go through each of these from top to bottom and use the first one it finds to wrap the templates in from your current active theme.
We’ve started tracking some plugins we like here https://codex.bbpress.org/feature-plugins-tracking/
We have no specific plans to include any of these in bbPress at this stage but things can change đŸ˜‰
thank you for reply, i was tested as you suggested and found problem in theme it is working fine in other theme but not in x2 theme also contacted to theme support but they told me this is plugin issue please suggest other way like how we break the loop of forum or group page by hard code.
you don’t actually need to change the permalinks eg is Kazza were user 15
http://www.mysite.com/forums/users/15/edit/
works just as well as
http://www.mysite.com/fourms/users/kazza/edit
so you’d need to change how the profile page is called so that it displays the no. in the url.
Given that profile is called from
any topic or reply display (click the avatar or author name)
several widgets (click the avatar or author name)
possibly other areas
you’d need to re-code these areas.
the function bbp_reply_author_link is used for topic and reply display, not sure if widgets use that as well.
Ok, not quite sure why that stopped working – it used to !
But have just tested this :
function display_counts ()
{
$user_id=bbp_get_reply_author_id( $reply_id ) ;
$topics = bbp_get_user_topic_count_raw( $user_id);
$replies = bbp_get_user_reply_count_raw( $user_id);
$post_count = (int) $topics + $replies;
echo "<br>Total posts : " ;
echo $post_count ;
echo "</br>" ;
}
add_action ('bbp_theme_after_reply_author_details', 'display_counts') ;
and that works.
As before you can then add some if statements to display a status or icon
yes just tried it, and it does say 0 – will come back to you – I just cribbed some code within a larger file that it worked several months ago – will take a closer look !
Yes, but depends on how code savvy you are.
Basically adding this to your functions file will get a count showing
function display_counts ()
{
$post_count = bbp_get_user_post_count( bbp_get_reply_author_id( $reply_id )) ;
echo "<br>Total posts : " ;
echo $post_count ;
echo "</br>" ;
//add some if statements here eg if $post_count>100 echo 'hero' or a link to a picture
}
add_action ('bbp_theme_after_reply_author_details', 'display_counts') ;
and where I’ve indicated adding some if statements link to icons or words will do the second
hmm..
with bbPress you should have a login widget that takes them to the bbPress profile,
I add the following code to it to make editing obvious
<p><a href="<?php bbp_user_profile_url( bbp_get_current_user_id() ); ?>edit" >Amend Profile/Change password</a></p>
You should be able to use that in your widget, or use it to substitute
Just thought I’d reply to przwilson:
I had the same problem and spent an entire day looking for the code. But I just found it.
IT’s at bbpress/includes/common/shortcodes.php
Around line 522 for me you’ll see the “largest” and “smallest” stuff. Edit it there and your problem is fixed. All you need to do is change the numbers.
Cheers.
I’m very new to bbpress but have been working with WordPress for quite a while. I have a WordPress form (displayed using a custom page template) to post solution here: http://pinkishhue.com/an-alternative-to-tdo-mini-forms-for-wordpress/#workingsolution
Perhaps this code could be altered to insert the post as a forum post instead of a regular post? Sounds like it shouldn’t be too complicated (maybe!)
Hope that helps.
Yes, I was giving you the sort of code you need to write, in this case to write stuff to usermeta.
As I said this is not a bbPress issue as bbPress just uses wp-posts, so you’d do better on their forum
“On this forum you have a nice clean bar showing create topic favorites and subscriptions, how can I create this on my forum. Does not have to be exactly the same but similar.”
Answered in another post
“Not sure if that’s the correct way to go about it but seems to work!”
Suggest you read the setting up guides for how and where to change templates
Codex
“Also how can i fix the subscribe button/link as it is not displayed very well as you can see here. ”
Agree, not quite sure where this displays, will look when I get a moment
‘Also i created a page which i put the shortcode for new topic form which i link to from the main forum page as a button. this is great but the form does not display well on the page. How can i fix this? the forum is really spaced out as you can see here ‘
Not quite sure what this photo is showing, the button or the resultant page? Can you post the method or code you used on the “main forum page”
I have the below code in my menu to add login & register. it is working fine but I just want to redirect the profile link to bbpress profile page instead of going to wp-login. Currently user role displays in the place of register after logged in, it will be great if some one help me to get “Welcome username” and link to bbpress profile page.
Thanks so much in advance…
add_filter(‘wp_nav_menu_items’, ‘add_login_logout_link’, 10, 2);
function add_login_logout_link($items, $args) {
if( $args->theme_location == ‘top-menu’ ) {
$loginoutlink = wp_loginout(‘index.php’, false);
$registerlink = wp_register(”, ”, false);
$items .= ‘<li class=”menu-item login”>’. $loginoutlink .” . ‘<li class=”menu-item register”>’ . $registerlink . ”;
}
return $items;
}
Would be great if anyone has any suggestions on how to fix these things.
I have now fixed the net topic form. I basically created a template for that page, pulling the code from form-topic.php
Not sure if that’s the correct way to go about it but seems to work!
Hi all. Same here. This fixed the problem. Place inside the functions.php:
function custom_bbp_has_replies() {
$args['orderby'] = 'ID';
$args['order'] = 'ASC';
return $args;
}
add_filter('bbp_before_has_replies_parse_args', 'custom_bbp_has_replies' );
function custom_bbp_show_lead_topic( $show_lead ) {
$show_lead[] = 'true';
return $show_lead;
}
add_filter('bbp_show_lead_topic', 'custom_bbp_show_lead_topic' );