ok, I’d either
change the theme to parent briefly and try it again – see if this fixes
or try replicating to a test site, where you can play with it
https://codex.bbpress.org/getting-started/testing-your-bbpress-installation/creating-a-test-site/
Thanks Robin W, it worked!. The working code is below for others help.
/**
* Add bbp user profile link in WP nav menu
* Filter wp_nav_menu() to add profile link
*/
function prefix_bbp_profile_link_nav_menu($menu) {
if ( !is_user_logged_in() )
return $menu;
else
$current_user = wp_get_current_user();
$user = $current_user->ID;
$bbp_profile_url = bbp_get_user_profile_url( $user);
$bbp_profile_menu_link = '<li>
<a href=" '. esc_url( $bbp_profile_url ) .' "> '. __('Edit Profile', 'text-domain' ) .' </a>
</li>';
$menu = $menu . $bbp_profile_menu_link;
return $menu;
}
add_filter( 'wp_nav_menu_items', 'prefix_bbp_profile_link_nav_menu' );
the last set of code in this thread should give you what you want
https://bbpress.org/forums/topic/adding-user-profile-button/
It’s been a while since I tried it, I’ll have to re-attempt it in a couple of days when I have an opportunity to try it again.
Cool
As I recall, it imported the users fine, and then it looked like it was doing the posts, but after, I want to say about 150 posts, it froze there, never indicated further imports. When I checked the database tables, it didn’t appear that it actually brought the content from Dizkus over to bbPress at all.
Ok, so it did something, thats a good sign in that the database name and password were correct.
If you’ve ever used Chrome/Firefox “inspect” debugger, you can right click and select “inspect” or (view the source code of the web page) and there is some extra debugging MySQL statements you will see there, if when testing you have issues take a look at the last query and include that MySQL code here when posting back, it will help determine what went wrong.
As to the localhost problem, I mirrored the Zikula site to my local WIn 10 machine, and then tried to import on a local WP/bbP site and it didn’t do anything. Seems like it just couldn’t find data.
If it can’t find any data it should thrown an error message to that affect, if you don’t select Dizkus from the dropdown menu on the importer screen and use the default AEF that can be one of the causes, another is that the database is not in the same database server as your WordPress install.
Did you import that database to your Win 10 machine or were you trying to connect to it remotely?
Hi, I am trying to add forum user profile link into wp_nav_menu_items.
Is there any way to get the forum root slug field value dynamically (just like user nickname, see $user in below code) to making the profile link dynamic? I am thinking to adding a setting option for getting the forum root slug from users in case no way to get the forum root slug fieled value.
Could anyone help? Thanks in advance.
/**
* Add bbp user profile link in WP nav menu
* Filter wp_nav_menu() to add profile link
*/
function prefix_bbp_profile_link_nav_menu($menu) {
if ( !is_user_logged_in() )
return $menu;
else
$home_url = home_url( '/' );
$current_user = wp_get_current_user();
$user = $current_user->user_nicename ;
$profilelink = '<li>
<a href="' . esc_url( $home_url ) . '/forum-slug/users/' . $user . '/edit"> '. __('Edit Profile', 'text-domain' ) .' </a>
</li>';
$menu = $menu . $profilelink;
return $menu;
}
add_filter( 'wp_nav_menu_items', 'prefix_bbp_profile_link_nav_menu' );
I’d look in wp-config for
define( 'WP_DEBUG', false );
and change it to
define( 'WP_DEBUG', true );
This will switch debugging on, and you should get an error shown when you try and access the site.
Post this error back here, and we’ll try to help further.
yes it goes in the functions file of your child theme
Functions files and child themes – explained !
Where would this code be added? I’m trying to do the same by adding it to my child theme’s bbpress.php file, but is just showing the raw code on the page. I may be in the wrong file, or else have something else missing. Thanks if you can direct.
It took me a ridiculous amount of time to find where to make this change and make it, and even then it is in the main bbPress code. I couldn’t get it to see anything I put in my child theme, because it is accessed through plugins, not themes. I know I’ll have to update the file again manually as soon as I update bbPress.
Also, that plugin only allows you to add new fields, not display existing ones. Doesn’t it seem odd that you would be prompted to enter data in fields on user profile edit, but then not have any of them show on view? By default the user fields should be available to show, at least standard ones like description, website, and social media profiles.
If you use that plugin to manually create some of those fields, your users will see two of each, the original ones that won’t show in view mode, and the custom ones you created. Not workable.
So really I see nothing to do other than manually editing the user-profile.php file to line by line include each field you want to show. How are some people not caring about this? It just seems so fundamental to me. Why go all the way to something like BuddyPress when all you want is field data already being collected to actually show?
The functions file of your theme might hold code that relies on bbpress – look for lines that include
add_action (‘bbp_something…
or
add_filter (‘bbp_something…
Answering to myself:
bbp_buddypress_loaded fires before everything is, in fact, fully loaded. bbPress’s component-specific extensions aren’t loaded until bp_init:7 (ty @boonebgorges for this explanation).
Changing add_action to bp_init with a priority of 8 did the job !
This may work for Site Activities, Members and Group activities
function bpfr_remove_activity_dropdown_label() {
// Remove forum filters in site wide activity streams
remove_action( 'bp_activity_filter_options', array( bbpress()->extend->buddypress->activity , 'activity_filter_options' ), 10 );
// Remove forum filters in single member activity streams
remove_action( 'bp_member_activity_filter_options', array( bbpress()->extend->buddypress->activity , 'activity_filter_options' ), 10 );
// Remove forum filters in single group activity streams
remove_action( 'bp_group_activity_filter_options', array( bbpress()->extend->buddypress->activity , 'activity_filter_options' ), 10 );
}
add_action( 'bp_init', 'bpfr_remove_activity_dropdown_label', 8 );
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