A lot of work ? Looks very nice. I had to check source code to see if you are cheating. 🙂
This seem to works. Or seems to work, I never know difference.
add_filter('bbp_before_get_reply_author_role_parse_args', 'ntwb_bbpress_reply_css_role' );
function ntwb_bbpress_reply_css_role() {
$role = strtolower( bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ) );
$args['class'] = 'bbp-author-role bbp-author-role-' . $role;
$args['before'] = '';
$args['after'] = '';
return $args;
}
add_filter('bbp_before_get_topic_author_role_parse_args', 'ntwb_bbpress_topic_css_role' );
function ntwb_bbpress_topic_css_role() {
$role = strtolower( bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ) );
$args['class'] = 'bbp-author-role bbp-author-role-' . $role;
$args['before'] = '';
$args['after'] = '';
return $args;
}
you could try something like the following in your function file (not tested)
add_action ('bbp_template_after_replies_loop', 'bbp_breadcrumb' );
Hm, it shows this error…
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'bb_auth_reply_view' not found or invalid function name in ..../blog/wp-includes/plugin.php on line 213
I thought I can do it with a filter in functions.php.
unfortunately not that easy if you don’t want to show the replies, as the loop-replies file has no easy filter to hook to !
yes you can put this in your main theme, just be aware itr will get overwritten by any theme update, so keep a good note of what you did, so you can do it again if needed.
create a directory on your theme called ‘bbpress’
ie wp-content/%your-theme-name%/bbpress
find
wp-content/plugins/bbpress/templates/default/bbpress/loop-replies.php
Make a copy of this file, and put in in the directory called bbpress that you created above, so you end up with
wp-content/%your-theme-name%/bbpress/loop-replies.php
bbPress will now use this template instead of the original
so that gets the right file
I wish I had time to write a solution for you for free, but I’m tied up in other work.
but basically you want to look at lines
<?php while ( bbp_replies() ) : bbp_the_reply(); ?>
<?php bbp_get_template_part( 'loop', 'single-reply' ); ?>
You want to stop it getting the template loop-single-reply if it is after pos 1, so something like
<?php while ( bbp_replies() ) : bbp_the_reply(); ?>
<?php // if user is not logged in and is the first reply
if( !is_user_logged_in() && $rep_position =2 ) {
echo "Replies only viewable for logged in users";
}
// if user is not logged in and is after the forst reply, then don't do naything
elseif( !is_user_logged_in() && $rep_position >2 ) {
}
//otherwise carry on as usual
else bbp_get_template_part( 'loop', 'single-reply' ); ?>
I thought I can do it with a filter in functions.php.
Don’t want to setup a child theme for this.
Is it possible to do it with just adding a additonal bbpress file to my theme?
My php-code knowledge is just search, copy and paste 😉
Thanks
Matthias
the filter is just applying to the reply content.
You probably want to amend a template – How php code/wordpress knowledgable are you?
I found a nice code, that shows the first message in a thread for everyone.
Answer are shown only to logged in users.
Perfekt so far.
BUT the code shows in every answer the same message for non logged users
“Replies only viewable for logged in users”
Does anyone know, how to change the code, to show only one template-notice
“Replies only viewable for logged in users” instead?
function bb_auth_reply_view( $reply_id ) {
$reply_id = bbp_get_reply_id( $reply_id );
// Check if password is required
if ( post_password_required( $reply_id ) )
return get_the_password_form();
$content = get_post_field( 'post_content', $reply_id );
// first topic reply shouldn't be hiding
$rep_position = bbp_get_reply_position($reply_id);
// if user is not logged in and not the first post topic
if( !is_user_logged_in() && $rep_position > 1 ) {
return "Replies only viewable for logged in users";
} else {
// return normal
return $content;
}
}
add_filter( 'bbp_get_reply_content', 'bb_auth_reply_view' );
Thanks
Matthias
The you’ll need to add it into a function and add it to two actions
‘bbp_theme_before_reply_content’
and
‘bbp_theme_after_reply_content’
so for example
Function agbams_share () {
your code in here
}
add_action ('bbp_theme_after_reply_content' , 'agbams_share' ) ;
add_action ('bbp_theme_after_reply_content' , 'agbams_share' ) ;
see
Step by step guide to setting up a bbPress forum – part 4
it will all depend on the order that the different css files bare loaded, so bbpress may be overwriting your theme ones
try
{
font-size: 13px !important;
}
That says ‘don’t overwrite’
add_action( 'bp_before_member_header_meta', 'devb_show_role_on_profile');
function devb_show_role_on_profile(){
global $wp_roles;
$user_id = bp_displayed_user_id();
$user = get_userdata( $user_id );
$roles = $user->roles;
if( !$roles)
return ;
if ( !isset( $wp_roles ) )
$wp_roles = new WP_Roles();
$named_roles = array();
foreach( $roles as $role ){
$named_roles [] = $wp_roles->role_names[$role];
}
if( $named_roles )
echo '<span class="user-role activity">'. join( ', ', $named_roles ) . '</span>';
}
Showing User role on BuddyPress Profile
hey guys, im a complete noob to this whole CSS and webdesign stuff and need some help
I am trying to increase the size of the font in the forum titles, (the info, topic, replies and freshness)
i used this piece of css code but it isn’t working
#bbpress-forums ul.bbp-lead-topic,
#bbpress-forums ul.bbp-topics,
#bbpress-forums ul.bbp-forums,
#bbpress-forums ul.bbp-replies,
#bbpress-forums ul.bbp-search-results
{
font-size: 13px;
}
(the theme i am using gives me a built in css sheet to pop any snippets that i may require in there and updates it live without going into the back end)
here is the link to my forum.
http://kamikazenoodle.co.uk/forums/
Hello to all the bbPress Scientists out there.
I am almost mad about to show bbPress User Role on BuddyPress Profile Page. And I am currently using this code, but it is not perfect and correct.
function show_user_role ()
{
global $bp;
$reply_id = bbp_get_reply_id( $reply_id );
$abc_role = bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) );
echo '<span class="profile-role ' . $abc_role . '"><i class="fa fa-star"></i> <em>';
echo $abc_role;
echo '</em></span>';
}
add_action( 'bp_before_member_header_meta', 'show_user_role' );
The demo output can be seen on http://www.punjabi.cc/ website by visiting any members profile.
First problem with this code is, it does not show correct name for dynamic roles when user is not logged in.
Second problem, the users who are blocked also tagged ‘Member’ not ‘Blocked’.
Please either correct it or provide me a another perfect piece of code, I will be highly thankful.
Regards,
Laddi
How do I go about getting into and editing the coding for the “img” button?
Currently the code that is applied is (img src=”xxxxxxxx” alt=”ffs” /) with the ( ) being < > and the xxx’s being the images URL.
I want to change the coding to (url=xxxxx)(img)xxxxx(/img)(/url) with the parentheses replaced with square brackets and xxxxx with the photo’s url.
By doing so, the images can be clicked which would open a lightbox
Thanks in advance for the help.
Wordpress 4.1
bbPress 2.5.4-5380
Well, Robin, I just heard back from my host provider and all possible checks were done and an error code:
Code:
brk(0x5419000) = 0x5419000
— SIGSEGV (Segmentation fault) @ 0 (0) —
is what was found and they said it’s back to you.
Now what?
Bob.
This is a theme issue.
You need to get bbpress to use the right theme template if possible.
Suggest you look at
Step by step guide to setting up a bbPress forum – Part 1
and/or check with the theme author
Hello. I have been trying to rename the navigation menu “forum” within groups.
Currently, I have this code implemented
function jm_move_group_activity_tab() {
global $bp;
if (isset($bp->groups->current_group->slug) && $bp->groups->current_group->slug == $bp->current_item) {
$bp->bp_options_nav[$bp->groups->current_group->slug]['forum']['name'] = 'new name';
$bp->bp_options_nav[$bp->groups->current_group->slug]['home']['name'] = 'new name';
$bp->bp_options_nav[$bp->groups->current_group->slug]['members']['name'] = 'new name';
$bp->bp_options_nav[$bp->groups->current_group->slug]['admin']['name'] = 'new name';
$bp->bp_options_nav[$bp->groups->current_group->slug]['send-invites']['name'] = 'new name';
}
}
add_action('bp_init', 'jm_move_group_activity_tab');
Everything works except for ‘forum’
Yes I have the code, but the file to edit and where exactly to paste the code.
Do you know what the code is that you would add at that location?
ok, gentle response !!
your forum is sitting within a class of .entry-content which is set to max-width: 474px;
so you need to add
.entry-content {
max-width: 100% !important;
}
to your theme style.css at the end
Strictly speaking you should add this to a child theme
Functions files and child themes – explained !
but if you add it to your main theme, juts keep a note of it, as you will need to re-add it should your theme be updated
Come back if anything not clear, and I’ll help further !
I want to add ShareThis sharing button at the top and bottom of every posts, but I dont know which file to edit and where exactly to add the code. Please someone guide me through. Am using bbpress 2.5.4 wordpress 4.1
you can have a look at this screenshot to understand what I really need,
http://s1382.photobucket.com/albums/ah248agbams/?action=view¤t=sharethis_zps1df4998b.png
ok, I’m planning to write some code for another purpose that will be using this function in the next few days, when I do I’ll take a look
Hi there,
I’m looking for an option to hold new topics by non-admin users in moderation for approval before they are visible. I’ve tried looking at this plugin: https://wordpress.org/plugins/bbpressmoderation/ but it deals with topics and replies together- you have to moderate both or not moderate both. I’m not interested in moderating replies, just topic starters.
Could anybody by any chance suggest a different plugin, a code snippet to use etc. to work around this issue?
(I’m running the latest versions on WordPress, BuddyPress and bbPress).
Thank you very much!
I had to create several new users but I could not just copied and paste the code again so I modified the code a bit
//code to add expert role
function add_expert_role( $bbp_roles )
{
/* Add a role called expert */
$bbp_roles['bbp_expert'] = array(
'name' => 'expert',
'capabilities' => custom_capabilities_expert( 'bbp_expert' )
);
return $bbp_roles;
}
add_filter( 'bbp_get_dynamic_roles', 'add_expert_role', 1 );
function expert_role_caps_filter( $caps, $role )
{
/* Only filter for roles we are interested in! */
if( $role == 'bbp_expert' )
$caps = custom_capabilities_expert( $role );
return $caps;
}
add_filter( 'bbp_get_caps_for_role', 'expert_role_caps_filter', 10, 2 );
function custom_capabilities_expert( $role )
{
switch ( $role )
{
/* Capabilities for 'expert' role */
case 'bbp_expert':
return array(
// Primary caps
'spectate' => true,
'participate' => true,
'moderate' => false,
'throttle' => false,
'view_trash' => false,
// Forum caps
'publish_forums' => false,
'edit_forums' => false,
'edit_others_forums' => false,
'delete_forums' => false,
'delete_others_forums' => false,
'read_private_forums' => true,
'read_hidden_forums' => false,
// Topic caps
'publish_topics' => true,
'edit_topics' => true,
'edit_others_topics' => false,
'delete_topics' => false,
'delete_others_topics' => false,
'read_private_topics' => true,
// Reply caps
'publish_replies' => true,
'edit_replies' => true,
'edit_others_replies' => false,
'delete_replies' => false,
'delete_others_replies' => false,
'read_private_replies' => true,
// Topic tag caps
'manage_topic_tags' => false,
'edit_topic_tags' => false,
'delete_topic_tags' => false,
'assign_topic_tags' => true,
);
break;
default :
return $role;
}
}
This creates the role Expert. I put this in my functions.php of my child-theme