Shortcodes
and to customise and style bbpress try
bbp style pack
i want to show forums on my own theme but i don’t know how. does bbpress provide shortcodes?
Hi Robin, Oddly enough the Subscribed forums is the only chunk that has issues with this setup. It ignores the current user with the below code. See result at https://obeii.com/discussions-subscriptions/
<?php do_action( 'bbp_template_before_user_subscriptions' ); ?>
<?php if ( bbp_is_subscriptions_active() ) : ?>
<?php if ( bbp_is_user_home() || current_user_can( 'edit_users' ) ) : ?>
<div id="bbp-user-subscriptions" class="bbp-user-subscriptions">
<h2 class="entry-title"><?php _e( 'Subscribed Forums', 'bbpress' ); ?></h2>
<div class="bbp-user-section">
<?php $user_id = get_current_user_id() ; ?>
<?php if ( bbp_get_user_forum_subscriptions($user_id) ) : ?>
<?php bbp_get_template_part( 'loop', 'forums' ); ?>
<?php else : ?>
<p><?php bbp_is_user_home() ? _e( 'You are not currently subscribed to any forums.', 'bbpress' ) : _e( 'This user is not currently subscribed to any forums.', 'bbpress' ); ?></p>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'bbp_template_after_user_subscriptions' ); ?>
untested, but try
<?php do_action( 'bbp_template_before_user_topics_created' ); ?>
<div id="bbp-user-topics-started" class="bbp-user-topics-started">
<div class="bbp-user-section">
<?php $user_id = get_current_user_id() ; ?>
<?php if ( bbp_get_user_topics_started($user_id ) ) : ?>
<?php bbp_get_template_part( 'pagination', 'topics' ); ?>
<?php bbp_get_template_part( 'loop', 'topics' ); ?>
<?php bbp_get_template_part( 'pagination', 'topics' ); ?>
<?php else : ?>
<p><?php bbp_is_user_home() ? _e( 'You have not started any topics.', 'bbpress' ) : _e( 'This user has not started any topics.', 'bbpress' ); ?></p>
<?php endif; ?>
</div>
</div><!-- #bbp-user-topics-started -->
<?php do_action( 'bbp_template_after_user_topics_created' ); ?>
This sets the user up as current user
I’m customizing my buddypress/bbpress user pages to be taken out of their traditional framework and placing that data on indvidual pages. However, when I do this the code has issues recognizing the current user and automatically ignores the logged in user. Does anyone know how to resolve this issue?
URL: http://obeii.com/discussions-topics-started/
CODE: (topics started)
<?php do_action( 'bbp_template_before_user_topics_created' ); ?>
<div id="bbp-user-topics-started" class="bbp-user-topics-started">
<div class="bbp-user-section">
<?php if ( bbp_get_user_topics_started() ) : ?>
<?php bbp_get_template_part( 'pagination', 'topics' ); ?>
<?php bbp_get_template_part( 'loop', 'topics' ); ?>
<?php bbp_get_template_part( 'pagination', 'topics' ); ?>
<?php else : ?>
<p><?php bbp_is_user_home() ? _e( 'You have not started any topics.', 'bbpress' ) : _e( 'This user has not started any topics.', 'bbpress' ); ?></p>
<?php endif; ?>
</div>
</div><!-- #bbp-user-topics-started -->
<?php do_action( 'bbp_template_after_user_topics_created' ); ?>
that code alters the names, but doesn’t help me in the ‘status legend’ – how is that legend created ?
Hello @robin-w, this is the code
add_filter( 'bbp_get_dynamic_roles', 'ntwb_bbpress_custom_role_names' );
function ntwb_bbpress_custom_role_names() {
return array(
// Keymaster
bbp_get_keymaster_role() => array(
'name' => 'Amministratore',
'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() )
),
// Moderator
bbp_get_moderator_role() => array(
'name' => 'Moderatore',
'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() )
),
// Participant
bbp_get_participant_role() => array(
'name' => 'Utente',
'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() )
),
// Spectator
bbp_get_spectator_role() => array(
'name' => 'Visitatore',
'capabilities' => bbp_get_caps_for_role( bbp_get_spectator_role() )
),
// Blocked
bbp_get_blocked_role() => array(
'name' => 'Bannato',
'capabilities' => bbp_get_caps_for_role( bbp_get_blocked_role() )
)
);
}
you will need to post the code you put in your functions file that does the status legend
it is not good practise to amend bbpress (or any plugin) files.
The code should go in the custom css area of your there if it has one, or via a plugin such as https://en-gb.wordpress.org/plugins/simple-custom-css/
for the threads are, the simplest would be to use my style pack plugin
bbp style pack
and change the roles in
dashboard>settings>bbp style pack>forum roles
for your specific area, we would need the code you added in your functions file, but that should be able to then use the plugin settings above
Hello BBPRESS community,
I really want to change color of my usergroups in my forum made by bbpress.
I have the standard role (keymaster, moderator, blocked ecc) but with names modified by editing the file functions.php in my theme folder.
Now I would like to change the color in the status bar and in the topic/threads, example Administrator in the red, moderators in blue ecc.
I tried a insert this code in bbpress/templates/default/css/bbpress.css:
.bbp-author-role-keymaster {
background:blue;
color:white;
padding:0 5px;
}
but it does not change anything, why?
I want to change color here
View post on imgur.com
and in threads/topic discussion.
How I do?
Thank you very much.
Got an error when the user no longer exists.
Edited your code, this one doesn’t give an error and hides the PM link:
function ntwb_bbp_bp_pm() {
if(function_exists('bp_send_private_message_link') && is_user_logged_in() ) {
global $bp;
if ($bp->loggedin_user->id !== bbp_get_reply_author_id()){
$user = get_userdata( bbp_get_reply_author_id() );
if ( !empty( $user->user_nicename ) ) {
$user_nicename = $user->user_nicename;
$compose = bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . $user_nicename;
?>
<div class="forum-pm"><a href="<?php echo $compose ?>" title="Private Message">Private Message</a></div>
<?php
}
}
}
}
add_action( 'bbp_theme_after_reply_author_details', 'ntwb_bbp_bp_pm' );
Thank you very much for your code shpitzyl.
Hey, this is a bit of a unique situation, so I’m not sure how much you’ll be able to help. We had a bbPress forum which we closed in 2015. The “topics” we migrated to a custom post type so that we could keep them published, but without the forum framework.
Recently, we’ve decided to re-open the forums on a new site. I exported the Forums, the Topics (which I switched back to the “topic” custom post type), and the Replies. We’re having two issues:
1) The topics are not longer associated with their respective forums. Same for the replies with their topics. I know we can manually re-associate them, but there are hundreds of topics and replies. I’ve tried the Repair tool under the Tools menu, but it didn’t fix anything. Are there any other options?
2) Additionally, the replies are not appearing in admin at all. I can see that there are 300+ published replies but where the list should be, I instead get this fatal error:
Fatal error</b>: Allowed memory size of 33554432 bytes exhausted (tried to allocate 4096 bytes) in <b>xxxxxx\wp-includes\class-wp-hook.php</b> on line <b>279</b>
Any help on either of these would be much appreciated. Thanks!
Hi @pauldlb
Try this… Paste the follow code into function.php (Appearance – Editor – Functions.php)
/* Remove SideBar From bbPress Profiles and Topics*/
function disable_all_widgets( $sidebars_widgets ) {
if ( function_exists('is_bbpress') ) {
if (is_bbpress()) {
$sidebars_widgets = array(false);
remove_all_actions('bp_register_widgets');
unregister_sidebar( 'bp_core_widgets' );
}
}
return $sidebars_widgets;
}
add_filter('sidebars_widgets', 'disable_all_widgets', 1, 1);
Checkout the phpBB converter, it’s one of the best example implementations.
Use _bbp_old_topic_id to grab your old topic id:
https://bbpress.trac.wordpress.org/browser/trunk/src/includes/admin/converters/phpBB.php#L183
p.s. The above phpBB converter uses bbPress 2.6 alpha which has many new refinements for the importer over bbPress 2.5, I’d suggest you use bbPress 2.6 alpha for any imports due to those improvements, it can be found here https://bbpress.org/download (bbPress.org and wordpress.org both use bbPress 2.6)
I get the error message “Oh bother! No topics were found here!”. I have installed bbpress and working on a divi theme. My shortcode for forum works but not my topics or index short code and I get this error. https://motionspecificrelease.ca/msr-community/
tools.php
function bbp_admin_repair_user_favorites() {
643 $values[] = "('{$user->user_id}', '{$key}, '{$favorites_joined}')";
Should be
function bbp_admin_repair_user_favorites() {
643 $values[] = "('{$user->user_id}', '{$key}','{$favorites_joined}')";
You can put a default IP for all registered activity:
add_filter( 'bbp_current_author_ip', function() {
return '127.0.0.1';
} );
127.0.0.1 is the default ip in this case.
@atmojones @slomeli79 @cjerrells
Can one of you give me a bit more instruction on where and how to enter this code? I get a syntax error when checking this code…
A little help would be hugely appreciated!
Code goes into the file functions.php that you can find on Appearance – Editor – Function.php. Open the file and paste it at the end. Just be careful because depending the theme code it can work fine or break your wordpress (if it breaks the wp just remove the code using cpanel or ftp).
The code allow you to upload featured image for bbpress forums. Then you can give it css style for a better looking.
To do this you need administrator access.
Thanks, Arutam!
I love Yoast. But, to be able to upload an image for sharing networks, doesn’t that require being able to access a URL in the Page editor? I think that’s the problem I’m having is there’s no way for me to do that. Does using this code supply that function?
And, where does the code get installed? I’m not a dev at all, so most of my knowledge is plug-and-play.
With follow code you can upload a featured image for forums… But if you want a good looking image on social networks I recommend you install Yoast (for example) to upload a custom image for share options.
/* Add Featured Image to bbPress Forums */
add_post_type_support('forum', array('thumbnail'));
function ks_forum_icons() {
if ( 'forum' == get_post_type() ) {
global $post;
if ( has_post_thumbnail($post->ID) )
echo get_the_post_thumbnail($post->ID,'thumbnail',array('class' => 'alignleft forum-icon'));
}
}
add_action('bbp_theme_before_forum_title','ks_forum_icons');
Source Link
Thanks for the follow up. Here is what I did…
- Disabled all plugins except bbpress
- I switched to a WP default theme, ie: twentyfifteen and twentyseventeen
- Did the above with Chrome, Firefox, and MS Edge browsers
Same thing still happens. So with the admin bar disabled, and logging in from the default WP login screen, and with bbpress enabled, I just get redirected to the site’s front page — no admin page. So I still have to add wp-admin/ at the end of the url address to get into the admin area. If I disable bbpress, then everything works normal. Enable it again, goes back to the issue.
As mentioned, I’ve encountered this for at least a couple years. So based on testing, it’s not theme related and not plugin (other plugins) related. Something about bbpress is redirecting after logging in with the default WP login and not sending me directly into the admin.
If there is something coded in bbpress for “Forum logging in” for front-end users, then I can see this being relevant. However, logging into the admin, is the problem.
I would love to know how to hide buttons like login or register when the user is logged in and vice versa for opposite scenarios.
Im surprised that’s not how it functions by default. Why can i access the log in page when im logged in? There should be redirect options for this.
Does anyone have any suggestions that does not involve a ton of code. Remember, that’s the whole point of WP and plugins.