Hey ! I’m searching for a way to add text in image. Juste like <quote>blabla</quote> but visible and with the image i decided to put before. Google did’nt help me at all and i’m a bit frustrated.
Thanks in advance for help.
Hey ! First, forgive me for my english, i’m french user of Bbpress.
So, as you can see here
i have the same title for two different category. Even if the second has for parent the first. I put this code http://pastebin.com/QypF9bhA in loop-forum-php. I’d like to have different title and mostly the true title of my category.
I saw someone with the same problem, cause permission plugin. For information i have bbp-private-groups, buddypress, buddymenu.
I hope this is clear.
In advance, thank you for your help.
@robkk, @peter-hamilton,
Ahhh ‘herd’, I read ‘nerd’ as a start.
There is a showcase list on our codex: https://codex.bbpress.org/showcase/
EDIT: Check this list: https://bbpress.org/about/examples/
Then there is a top100 of some years ago: http://bbshowcase.org/forums/view/top100
Let me see to update our codex showcase list a bit…
Pascal.
Ok, last time, I promise :p…
I updated all my users with the above function, but I don’t want it to run every time on the init hook.
So I changed it into:
/*
* Do stuff when the user's xprofile is updated
*/
function xprofile_updated ( $user_id, $posted_field_ids, $errors, $old_values, $new_values) {
/*
* Change the user_nicename which is used as profile url, we do NOT want the username in url! Bad bad BP...
* Please note: the user profile url can now be changed by the user, direct linking from other places on the web may result in 404.
* Altough this should run AFTER updating profile fields (saving to DB), the nicename is only updated after a second save. So we need to check from $new_values
*/
$new_display_name = '';
foreach ( $new_values as $key => $value ) {
if ( is_array($value) && $key == 1 ) { // field display_name = 1, make sure this is correct
foreach ( $value as $k => $v ) {
if ( $k == 'value' ) {
$new_display_name = $v;
}
}
}
}
//error_log('******** xprofile_updated: '.$user_id.' | NEW DISPLAY_NAME: '.$new_display_name.' *********');
$search = array( ' ', '.' );
$replace = array( '_', '' );
$user = get_user_by( 'ID', $user_id );
if ( $user ) {
if ( $user->data->user_status == 0 && $new_display_name ) {
$new_user_nicename = strtolower(str_replace( $search, $replace, $new_display_name) );
if ( strlen ( $new_user_nicename ) > 50 ) {
$new_user_nicename = substr ( $new_user_nicename, 0, 50 );
}
if ( $user->data->user_nicename != $new_user_nicename ) { // && $user->ID == 80 <-Add this if you only want to run it for 1 user, so you can test it.
$args = array(
'ID' => $user->ID,
'user_nicename' => $new_user_nicename
);
wp_update_user( $args );
//error_log('******** updated user_nicename: '.$user->ID.' | NEW USER_NICENAME: '.$new_user_nicename.' *********');
wp_redirect( get_site_url().'/leden/'.$new_user_nicename.'/profile/edit/group/1/' ); // we cant use bp_core_get_user_domain() here, because it still uses the old user_nicename
exit;
}
}
}
}
add_action( 'xprofile_updated_profile', 'xprofile_updated', 100, 5 );
Please note, it has some site specific code, like the wp_redirect.
Any questions? Feel free to ask.
@mod: Hoping my code snippet is not too long.
Regards, Bjorn
OMG… We webdesigners are never finished ๐
After some more testing I noticed that the function did not change all user_nicename.
The DB type of user_nicename = VARCHAR(50) and the type of display_name = VARCHAR(250).
If the updated user_nicename exceeds 50 chars the DB field will not update and nothing changes. So I added a substr to resolve this.
Thankfully the wp_update_user() takes care off special characters like รซ.
Updated code:
/*
* Change the user_nicename which is used as profile url, we do NOT want the username in url! Bad bad BP...
* This runs allways (with init hook), we should only do this once and then on user register & profile update..
* Please note: the user profile url can now be changed by the user, direct linking from other places on the web may result in 404.
* And offcourse allways use something like: 'bp_core_get_user_domain( $user_id )' when you want to get the user's profile url.
*/
$search = array( ' ', '.' );
$replace = array( '_', '' );
$all_users = get_users();
foreach ( $all_users as $user ) {
$display_name = $user->data->display_name;
if ( $user->data->user_status == 0 && $display_name ) {
$new_user_nicename = strtolower(str_replace( $search, $replace, $display_name) );
if ( strlen ( $new_user_nicename ) > 50 ) {
$new_user_nicename = substr ( $new_user_nicename, 0, 50 );
}
if ( $user->data->user_nicename != $new_user_nicename ) { // && $user->ID == 80 <-Add this if you only want to run it for 1 user, so you can test it.
$args = array(
'ID' => $user->ID,
'user_nicename' => $new_user_nicename
);
wp_update_user( $args );
}
}
}
LoL, I thought i was finished, but i noticed the second loop isn’t necessary.
So here’s my finished/tested code:
/*
* Change the user_nicename which is used as profile url, we do NOT want the username in url! Bad bad BP...
* This conversion runs allways, we should only do this once and then on user register & profile update..
* Please note: the user profile url can now be changed by the user, direct linking from other places on the web may result in 404.
* And offcourse allways use something like: 'bp_core_get_user_domain( $user_id )' when you want to get the user's profile url.
*/
$search = array( ' ', '.' );
$replace = array( '_', '' );
$all_users = get_users();
foreach ( $all_users as $user ) {
$display_name = $user->data->display_name;
if ( $user->data->user_status == 0 && $display_name ) {
$new_user_nicename = strtolower(str_replace( $search, $replace, $display_name) );
if ( $user->data->user_nicename != $new_user_nicename ) {
$args = array(
'ID' => $user->ID,
'user_nicename' => $new_user_nicename
);
wp_update_user( $args );
}
}
}
Put this in a function and call it on an action hook, can be done in your theme’s functions.php just like the OP already explained here.
The function will change something like this: ‘Mr. A.T. Testing123’ into ‘mr_at_testing123’.
Wanted to share my finished code:
// Change the user_nicename which is used as profile url, we do NOT want the username in url! Bad bad BP...
// Wheb using the 'init' action hook this will always run, we should only do this once and then on user register & profile update..
// Please note: the user profile url can now be changed by the user, direct linking from other places on the web may result in 404.
// And offcourse allways use something like: 'bp_core_get_user_domain( $user_id )' when you want to get the user's profile url.
$search = array( ' ', '.' );
$replace = array( '_', '' );
foreach ( get_users() as $user ) {
if ( $user->data->user_status == 0 && $user->data->user_nicename != strtolower(str_replace( $search, $replace, $user->data->display_name)) ) {
$user_ids[] = $user->ID;
}
}
foreach( $user_ids as $uid ) {
$user_data = get_userdata( $uid );
$display_name = $user_data->data->display_name;
if ($display_name) {
$args = array(
'ID' => $uid,
'user_nicename' => strtolower(str_replace( $search, $replace, $display_name))
);
wp_update_user( $args );
}
}
Thanks for sharing this! WHAT was BP thinking when they decided to use the username as profile url… I know why (only mandatory userdata on register), but imho the first thing to develop next is a solution to change this..
EDIT
When implementing your solution i found something.
Doing $user->data->user_nicename != $user->data->display_name in the first foreach loop will not work because when updating (second loop) the user_nicename you do a strtolower and str_replace.
If you want the check to work use the same conversion on the first loop.
WP 4.5.3 – BP 2.6 – bbP 2.6 alpha -2016
I want to remove the 2 bbp related options (topics & replies) from BP’s site wide activity filter dropdown.
I’m using this function, but it has no effect:
function remove_activity_filters( $bbp_buddypress = null ) {
if ( bp_is_active( 'activity' ) && bp_is_activity_component() ) {
// Remove forum filters in site wide activity streams
remove_action( 'bp_activity_filter_options', array( bbpress()->extend->buddypress->activity, 'activity_filter_options' ), 10 );
}
add_action( 'bbp_buddypress_loaded', 'remove_activity_filters' );
I dont get this logic, despite if it is only WP logic, not bbPress one.
Maybe I missunderstool it all. New Users (Roles = Subscriber, Participant) have access to add new Posts, and attach them to taxonomies.
Forum Users are forum USers, not Portal editors of Articles.
This code should be in bbPress core. When you install bbPress you accept that whole platform is changed to something else, and old WP rules are not valid anymore.
For all other things Users have buddyPress profile Pages.
function splen_remove_admin_bar() {
if( !is_super_admin() )
add_filter( 'show_admin_bar', '__return_false' );
}
add_action('wp', 'splen_remove_admin_bar');
//don't allow users to go wp-admin
add_action( 'init', 'blockusers_init' );
function blockusers_init() {
if ( is_admin() && ! current_user_can( 'administrator' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}
This code will do that
//add profile link to forums
add_action ( 'bbp_template_before_single_forum', 'rew_profile_link' ) ;
add_action ( 'bbp_template_before_forums_index', 'rew_profile_link' ) ;
function rew_profile_link () {
if (!is_user_logged_in())
return ;
$current_user = wp_get_current_user();
$user=$current_user->ID ;
$profile = 'Profile' ;
$user_link = '<a href="' . esc_url( bbp_get_user_profile_url( $user) ) . '">' . $profile . '</a>';
echo '<div style="text-align: center;">'.$user_link.'</div>';
}
ok
On issue 1
The code goes on then functions file of your child theme
https://codex.bbpress.org/functions-files-and-child-themes-explained/
on issue 2, pending 2.6 coming out containing a fix (neither currently has any timescales)
the you can achieve this with my private groups plugin
https://wordpress.org/plugins/bbp-private-groups/
see the help page for how to set up
@robkk – I’m just trying to help someone, not trying to get the most efficient code ๐
Robin there is a few functions already in bbPress that might be useful to use, and it might cut some of your code some.
http://hookr.io/plugins/bbpress/2.5.8/#index=u&search=bbp_user_profile
This should do what you want
//add profile link to forums
add_action ( 'bbp_template_before_single_forum', 'rew_profile_link' ) ;
add_action ( 'bbp_template_before_forums_index', 'rew_profile_link' ) ;
function rew_profile_link () {
if (!is_user_logged_in())
return ;
$current_user = wp_get_current_user();
$user=$current_user->user_nicename ;
$user_slug = get_option( '_bbp_user_slug' ) ;
if (get_option( '_bbp_include_root' ) == true ) {
$forum_slug = get_option( '_bbp_root_slug' ) ;
$slug = $forum_slug.'/'.$user_slug.'/' ;
}
else {
$slug=$user_slug . '/' ;
}
$edit_profile = __('Edit Profile', 'bbp-style-pack') ;
//get url
$url = get_site_url();
$profilelink = '<a href="'. $url .'/' .$slug. $user . '/edit">'.$edit_profile.'</a>';
echo '<div style="text-align: center;">'.$profilelink ;
}
add it to your functions file
https://codex.bbpress.org/functions-files-and-child-themes-explained/
not tested but this code should allow editing at all times. Add it to your functions file
add filter ('bbp_past_edit_lock' , 'rew_allow_editing' )
function rew_allow_editing () {
$retval = false ;
Return $retval ;
}
on other posts, I’d wonder if the bbp_reply_id(); might be returning a null or the wrong id.
As a test the easiest way would be to replace your Edit </a> with
<?php echo esc_url( home_url( '/' ) ).'conversations/reply/'.bbp_reply_id().'/edit/' ?></a>
That way you’ll see where it is going to send you and can find out what the problem is
Thanks for your help, Robin W. It worked. I just delete the code of lines 60 and 68 and saved the file.
You will need to change a template, so if you can edit a file and know FTP then you can amend this
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
find
wp-content/plugins/bbpress/templates/default/bbpress/loop-single-topic.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/themes/%your-theme-name%/bbpress/loop-single-topic.phpbbPress will now use this template instead of the original and you can amend this.
Now go to line 68, which says
<span class="bbp-topic-started-in"><?php printf( __( 'in: <a href="%1$s">%2$s</a>', 'bbpress' ), bbp_get_forum_permalink( bbp_get_topic_forum_id() ), bbp_get_forum_title( bbp_get_topic_forum_id() ) ); ?></span>
and delete this and save the file
Since there is a time limit to editing post and no way to set it to unlimited (I wonder why, but that’s a question for another day), I’ve set the limit to maximum. There also was an issue, where original “edit” button wouldn’t show up. I did a little research, and turned out that most of the time, it was theme conflict. Changing theme was not an option. So, I’ve just added a custom “edit” link to template. It looks like this
<a href="<?php echo esc_url( home_url( '/' ) ); ?>conversations/reply/<?php bbp_reply_id(); ?>/edit/" class="editbtn"> Edit</a>
It works fine with newer posts. But when I tried editing one of older posts, I got following error:
The mydomain.com page isnโt working
mydomain.com redirected you too many times.
I don’t think there is a character limit when you post a reply or topic with more than 300 characters.
Check to see if it could be some spam plugin with a feature for this, or a custom theme feature by doing the listed plugin and theme troubleshooting.
https://codex.bbpress.org/getting-started/troubleshooting/
@stevecl
The issue also does happen in TwentyFifteen.
The issue is because in the bbPress default theme package, there is a template called content-search.php. In some newer themes there is also a template of the same name. And since the bbPress templates don’t necessarily need to be in a bbPress folder, the bbPress plugin is choosing the template from your theme before the template that is actually in bbPress.
Copy content-search.php from the bbPress plugin templates and place it in a child theme in a folder called bbpress. This fixed the issue you are getting in a free version of your currently active theme.
https://codex.bbpress.org/themes/theme-compatibility/
Also just created a trac ticket for this issue.
https://bbpress.trac.wordpress.org/ticket/2966
Heyy hi, it is working as it is now when i insert this code in! Thanks!
@scootsafe
Since you enabled threaded replies, which has an issue with some mobile responsive styles because how they are by default. Try this custom CSS, or disable threaded replies and see if your forums have a better layout, though I am not sure how the mycred badges will react.
#bbpress-forums div.bbp-reply-author a.bbp-author-name {
display: block !important;
}
besides all the wonderful and appreciated help here on the bbpress forums, what do you do with bbpress?
I would love to see more websites showcased and since you @robkk are leading the herd now I am in need to see the best bbpress forums online from you, I bet you made a few by now.
I personally get a lot of inspiration looking at other forums and see how people make the code their own but can not find a descent showcase anywhere.
Looking forward to be amazed
Peter
@jon-fergus I suggest you do not add edit_others_topics to user roles so they can add inline images, it *WILL* allow them to *edit others topics** for whatever reason users cannot edit other topics as you suggest might be a bug, it might not be and maybe a conflict with your *adminimize hide dashboard* plugin and is obfuscated and easily bypassed.