Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 18 replies - 1 through 18 (of 18 total)
  • @timnicholson

    Participant

    BP v1.21 is very whacked out in how it handles user names and profile URL’s. I’m seeing inconsistencies all over the place. Sometimes it uses the users nicename and sometimes it seems to be using their display_name. It doesn’t handle spaces in the user name at all. With some code I found on these forums, I’ve been able to patch things up a bit, but its still a mess. Check out this thread: https://buddypress.org/forums/topic/all-links-are-working-minus-my-adminauthorall-of-my-pages.

    Fixing the issue with spaces in the user name is actually quite easy by adding a urlencode() function to the string that gets used to find the user. However, in most cases the spaces in the user name are appearing because BP is using the wrong user name for the lookup.

    @timnicholson

    Participant

    If anyone stumbles on this thread, there is another thread where I have replied at length about this: https://buddypress.org/forums/topic/activating-existing-users

    @timnicholson

    Participant

    What a nightmare this has been! Anyway, thanks to etiviti’s original code, I was able to patch up the bp-core/bp-core-catchuri.php file as follows. This is replacement code within the function bp_core_set_uri_globals(). The // is lines I commented out and I added // ADD to the new lines that replaced them.

    /* Catch a member page and set the current member ID */
    if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {
    //if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) {
    if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) { //ADD
    // We are within a member page, set up user id globals
    //$displayed_user_id = bp_core_get_displayed_userid( $bp_uri[1] );
    //$user_temp = get_user_by('slug', str_replace('%20',' ',$bp_uri[1]) ); //ADD
    $user_temp = get_user_by('slug', urldecode($bp_uri[1]) ); //ADD
    $displayed_user_id = $user_temp->ID; //ADD

    unset($bp_uri[0]);
    unset($bp_uri[1]);

    /* Reset the keys by merging with an empty array */
    $bp_uri = array_merge( array(), $bp_uri );
    }

    This code assumes that you will be using nicename for the URL’s so DO NOT set BP_ENABLE_USERNAME_COMPATIBILITY_MODE in wp-config.php. What this code does is look up the user by “slug”, which is what WP refers to the nice name as. Since I had to hack the code to get anything to work, I went ahead and fixed the issue with spaces being in the nice name as well. The function urldecode() will replace the %20 in the URL with the space that is needed for the “slug” lookup. In fact, it should fix similar issues with other characters in the user nicename field that get replaced when its converted to a URL.

    If you really want to fix this by using the user’s login name, original function call I commented out bp_core_get_displayed_userid() will accept a user login name (and ONLY a user login name… its not designed to accept “slugs” or full names or anything else). So you shouldn’t need However, the bigger issue with this is that the various BP pages seem to spit out many links using the nicename, not the user_login name.

    @timnicholson

    Participant

    Ok, this is *really* whacked. When setting BP_ENABLE_USERNAME_COMPATIBILITY_MODE to true in BP v1.2.1, this fixes the member profile link on the member *directory* page only by using the user login name. However, on the actual member profile page itself, the user nicename is still be used in all the links. The wrong name is also being used on all the activity stream pages. Could this be a cache issue that will resolve itself over time? I can’t see how this behavior would happen unless it was cache-related.

    @timnicholson

    Participant

    etiviti, I’m on BP v1.2.1 and the code I have in bp-core is different than what you have above. There is no reference to $_udl anywhere in bp-core-catchuri.

    I *do* see some code that looks like it should adress the issue, but doesn’t seem to work.

    function bp_core_get_username( $user_id, $user_nicename = false, $user_login = false ) {
    global $bp;

    if ( !$username = wp_cache_get( 'bp_user_username_' . $user_id, 'bp' ) ) {
    if ( empty( $user_nicename ) && empty( $user_login ) ) {
    $ud = false;

    if ( $bp->loggedin_user->id == $user_id )
    $ud = &$bp->loggedin_user->userdata;

    if ( $bp->displayed_user->id == $user_id )
    $ud = &$bp->displayed_user->userdata;

    if ( empty( $ud ) ) {
    if ( !$ud = bp_core_get_core_userdata( $user_id ) )
    return false;
    }

    $user_nicename = $ud->user_nicename;
    $user_login = $ud->user_login;
    }

    if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
    $username = $user_login;
    else
    $username = $user_nicename;
    }

    /* Add this to cache */
    if ( !empty( $username ) )
    wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' );

    return apply_filters( 'bp_core_get_username', $username );
    }

    Notice how the $username that gets returned should either be user_login or user_nicename, depending on whether BP_ENABLE_USERNAME_COMPATIBILITY_MODE is set or not. However, on all my BP pages, the user permalink is always showing the display_name with the space in it and the URL’s don’t work.

    Digging further, I see that the function that returns the link to the member profile, bp_get_member_permalink(), is defined in bp-core-templatetags and calls bp_core_get_user_domain(), which in turn bases the URL on the above function bp_core_get_username().

    So this SHOULD work, but doesn’t seem to. There IS some cache logic in the code above, so maybe that’s part of the issue but I still can’t for the life of me figure out how that code above could ever return a URL based on the user’s “display name”.

    @timnicholson

    Participant

    I would like to know this is as well? Is there an easy way to get BP to use the “user nicename” (which doesn’t have spaces)… or even the “login name” would be acceptable (although not preferred).

    @timnicholson

    Participant

    I’m having similar problems. All my users have spaces in their “display name”. I’ve also just changed up the code to make sure that the “user nicename” doesn’t have any spaces in it. The “login name” never has spaces. It appears that for the BP admin bar, the links use the login name and that seems to work fine. However, in all the BP pages (members, activity, etc.) the member profile link is built using their “display name” which has the space in it and when clicked you get sent to the home page.

    Is there any way to tell BP to use the “user nicename” for the permalinks instead of the “display name”?

    @timnicholson

    Participant

    Sorry to tack on to an old post, but this is EXACTLY the issue I’m having as well. AFAICT, BP is NOT building the member profile link using the login name. Its using the display name, which often times has spaces in it. In fact, since I’m using a Facebook Connect plugin, the display name ALWAYS has a space in it. I’ve modified that plugin to replace spaces with dashes in the user nicename, hoping BP would use that, but it doesn’t.

    Is there an easy way to get BP to use the nicename for the member profile URL? I’m thinking maybe a filter that can be added to bp-custom or the theme functions file, but I’m not sure if a filter exists and not sure if altering the link would mess up the “permalinks” (mod_rewrite).

    @timnicholson

    Participant

    r-a-y, I definitely understand that these days people like to consider older posts and forum threads dead after a short period of time. Some user just like to jump on old stuff without finding the answers in newer threads. However, when there is a dearth of information about a particular topic and people are trying to properly research before posting and all that comes up is old threads, I’m of the opinion that they should be resurrected. Why start a new post asking the same questions and diverging the threads? I’m actively searching for information about this and scrounging through PHP code and websites for answers. I’ve uncovered some good information that I’m trying to share, but am still looking for more answers. If I run a search and it returns all these “dead” threads and no new threads, the masses are going to as well.

    Plus, I just replied to other threads offering to help with questions you’ve asked here months ago to which I see no answers. If you’ve figured all this out, why not update those original threads with the answers for newer folks trying to figure things out? If you haven’t figured everything out, then why not be happy that the threads are going active again and information is being shared?

    Please don’t take this the wrong way, I just don’t understand why some forums seem to be filled with people complaining about “old” threads being responded to and others appreciate it. And why don’t the forums that are dead-set against replying to old threads, simply close out the old ones?

    @timnicholson

    Participant

    r-a-y, is there any way to get comments on blog and forum posts (in the BP activity pages) to actually add the comment to the WP blog post or as a reply to the forum post? This would be SO useful. The way it works now is that your user’s comments end up staying only within the BP activity stream and don’t get reflected on your actual main website (blog)! Disabling it prevents that, but also removes the convenience of user’s being able to comment globally from a single place on their BP activity stream pages.

    I have to believe this *should* be a pretty easy plugin to develop (depending on how modular the WP and BP code is around this), but would much rather see this built into BP core. I already have a dozen WP plugins that I feel are essential for any blog and as I look to roll out BP, that’s going to add many more. I’m tapping out a dedicated server as it is and all these hooks and plugins and template tags and such require some seriously beefy hardware.

    @timnicholson

    Participant

    seanx820, I’m pretty experienced in PHP, WP, and am now diving into BP (since it works on non-WPMU installs). I’ve done a lot of theme mods, including making changes to the navigation links, both in standard WP themes and now in BP themes. My site http://xtremelysocial.com sounds similar to what you are trying to do in that your blog is your main focus, but you want to add social-networking type features on top of that.

    One of the big challenges with BP is theme support. There are almost no BP themes out there and adding full BP support to an existing themes is very difficult. However, there are some resources for you to check out.

    Your best bet if you want to keep your current theme is to use this plugin. Its very basic and won’t have the BP sections in your site looking sharp, but it will work.

    https://wordpress.org/extend/plugins/bp-template-pack/

    Also, here are some more details on hacking themes for BP.

    https://codex.buddypress.org/how-to-guides/building-a-buddypress-child-theme/

    @timnicholson

    Participant

    I don’t think Dnorman said anything about using Multi-DB. Check this post for info on why existing WP users aren’t appearing in BP when you add that plugin. https://buddypress.org/forums/topic/activating-existing-users#post-39547

    @timnicholson

    Participant

    Alessandro, I’m a bit confused with what you are trying to do. It sounds like you have a normal (single) WP installation and are looking to go social with it. A lot has happened since you posted this and BuddyPress is now available for single WP installs. I’m testing it out now. In WP v3.0, WordPress MU will be merged with the single WP installation and there will be a migration path. I can help answer questions around this… just let me know some more specifics.

    @timnicholson

    Participant

    Enlightenmental1, I’m not sure if you are a developer or not, but if so there is a function called bp_core_get_total_member_count() in bp-core.php. That function will return the total number of members. However, keep in mind that this may be different than the total number of registered users in WP if you didn’t have BP up and running from day 1. If you are going to hack the core WP admin screens, you should make sure to check that the BP plugin is activated before calling that function.

    @timnicholson

    Participant

    Ok, here’s where I’m at so far. I found out what BP uses to determine if a WP user is a BP user. There is NOT a separate table for BP users. A WP user is considered a BP user if that user has performed ANY “activity”. The BP Members page displays ONLY users that have done something in BP.

    For example, when a new user registers, an activity is created saying that user registered. The standard WP user meta table (wp_usermeta) gets a record added for that User ID called “last_activity” and the meta value is the current date and time. Once a user has a last_activity record, then they are displayed in the BP Member directory. You’ll notice that in the Member directory it shows the total users, which should be your total number of WP users, but it also says “Viewing member 1 to x (of x active members”.

    I have verified this by manually adding a record to the user meta table for one of my users that registered before I was running BP. That person now shows in the BP member directory.

    Now I also see code in BP that attempts to update (or create if not found) the user’s last_activity meta record every 5 minutes while they are logged in. This is so that BP can show how long ago a particular user was “active” for various pages and widgets. I tested this by logging in as another WP user (non-BP user) and it added the record and now displays that person in the list. It also seems to have added that user’s full name in the BP custom profile field table (wp_bp_xprofile_data).

    So without doing ANYTHING, our BP member directory will grow as users log in to our site. This probably isn’t a bad thing because if there are users that registered a long time ago for some reason and don’t plan on ever coming back, why list them in the directory?

    However, I may still go ahead and try to figure out the best way to programatically add records for all the WP users. My site is new and since I only have 221 users, I’d like to have them added to BP, if for no other reason than for better testing of the plugin before I roll it out. I currently have BP activated, but have hidden all the menus so user’s don’t really know how to get to any of it. My site is at http://xtremelysocial.com if you want to check it out. Just go directly to a BP URL, such as http://xtremelysocial.com/activity/. I’m jacking around with adding BP support to my highly customized WP theme right now so if the formatting looks whacky, that’s why.

    I’ll post an update if I work something out programatically to add all the WP users to the BP member directory.

    @timnicholson

    Participant

    I’m seeing the same behavior where only new members are being added to BuddyPress. I don’t think it has anything to do with where things are installed. I don’t think BuddyPress attempts to add “old” WordPress-only users. You’ll also notice that past blog posts and comments, etc. aren’t shown in your BuddyPress activity stream. However, if you go into an “old” blog post and simply hit update, it gets added to the stream.

    What we need is a utility that can be run that will load all the existing WP users into BP. I’d also love to see one that will load up the BP activity stream with WP blog posts and comments as well, but that’s probably asking for too much.

    I did find a BuddyPress plugin that talks about being able to import users into BP. However, its not what we are looking for. It is designed to import a list of users that you cut-and-paste into a text box on the plugin. I checked the code and it will only work with WPMU and it will also (re)create whatever users you import into WP as well causing duplicates. https://wordpress.org/extend/plugins/user-import-for-buddypress-all-fields/

    I’m going to dig around in the BP core to see how it goes about keeping BP and WP users in sync and see how hard it would be to write a program or plugin that would simply trigger BP to add all the existing WP users that aren’t already in BP.

    @timnicholson

    Participant

    I agree that this is more difficult than it should be. I’m finding that when I try following the buddypress codex on this with using @imports, the admin bar works fine, but pulling in the default theme css screws up a lot of things. I’ve found that just grabbing the default buddypress theme’s css sytles that are in addition to the core wordpress ones is working better.

    I really think that the buddypress default theme should do a better job at segregating core wordpress css tags from the buddypress specific ones. The buddypress-specific css styles seem to be too dependend on the core wordpress ones. For example, core wordpress typically removes the dots from

  • entries and the wordpress sub-nav tabs assume that’s already done. I’d like to see the buddypress specific tabs assign all the css properties they need so those can be pasted into an existing theme with ease.
  • While I’m making progress, the time involved to get it perfect is too high. Not to mention buddypress really adds a lot of overhead and slows down my site. I haven’t even installed the bbpress forums yet as I’m scared to death of what that will do to site performance. I’m on a dedicated server, too, and its just not good.

    I’m thinking about writing a tutorial on my site http://xtremelysocial.com to document what I’m doing to help others with this. However, regarless of what tutorials get published, in the end there is just way too much css tweaking required.

@timnicholson

Participant

Erwin, it sounds like you are barking up the wrong tree with Facebook. I’m an FB app and connect developer and you don’t need to get anyone’s user ID and password. You connect their FB account with your website via the FB Connect javascript libraries and then you have access to their friends, etc. using the generated session key. All that TOS stuff you posted is just saying you can’t ask a user for his FB password and store it. You don’t need to know that person’s FB password to access their social graph.

I’d LOVE to see BuddyPress expanded to display FB friends, FB activity stream, etc. for a person’s friends whether or not they are a user of your website or not. I’m working on expanding a WordPress FB Connect plugin by http://sociable.es right now. I have it displaying all your FB friends and displaying your FB news stream. I need to work on stylesheets to get the stuff to look decent, but I have the core functionality up and running. Check out http://xtremelysocial.com. I want to add Twitter and MySpace support as well and also generate an ATOM feed (actually, better yet an http://activitystrea.ms format) with stream posts from ALL connected social network sites. Kind of like a friendfeed.com type site.

Viewing 18 replies - 1 through 18 (of 18 total)
Skip to toolbar