Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 25 replies - 1 through 25 (of 36 total)

  • terraling
    Participant

    @terraling

    Thanks @godavid33.

    I’d like to fix this without having to resort to a custom sql query.

    BuddyPress is designed to do this (sort alphabetically by display name rather than username) correctly.

    In the relevant code, it checks to see if WordPress-BuddyPress profile syncing is enabled. If it is, it runs the query against the wp_users table rather than the wp_bp_xprofile_data table, because “the table is smaller and better indexed”. If syncing is disabled then it runs the query against the xprofile display_name field instead.

    I have fixed the problem by turning off syncing so that it uses the xprofile display name, so my question is, what does profile syncing do exactly and when/how does it do it?

    I presume it overwrites nicename in wp_users with the display_name from xprofile (anything else?), but in my case it is not doing so, it appears broken.

    If I could identify the when/how then I’d be able to see if it is something I’ve broken or omitted in, for example, my custom registration page.


    terraling
    Participant

    @terraling

    Good question and the answer is it depends on the specific case. Some content is tied to its physical location (i.e. if the user moved the content would stay put), in other cases the location context is determined by the user (i.e. if the user moves the content goes with them).

    So I may need a bit of both.

    Thanks again, very helpful.


    terraling
    Participant

    @terraling

    OK, great, thank you. That’s enough to set me off on the right track.

    Currently what gets submitted for the members directory looks something like this (actual query), and it ain’t too pretty:

    SELECT u.ID, xpd1.value as UserLat, xpd2.value as UserLon, ( acos(sin(0.632743928228) * sin( RADIANS(xpd1.value) ) + cos(0.632743928228) * cos( RADIANS(xpd1.value ) ) * cos(-0.104081294481 - RADIANS(xpd2.value ) )) * 6371 ) as distance 
    FROM wp_users u JOIN wp_bp_xprofile_data xpd1
    ON xpd1.user_id = u.ID JOIN wp_bp_xprofile_data xpd2
    ON xpd2.user_id = u.ID 
    WHERE xpd1.field_id = 15 
    AND xpd2.field_id = 16 
    AND ( RADIANS(xpd1.value ) > 0.624895866699
    AND RADIANS(xpd1.value ) < 0.640591989757)
    AND ( RADIANS(xpd2.value ) > -0.113813472053
    AND RADIANS(xpd2.value ) < -0.0943491169082) 
    AND acos(sin(0.632743928228) * sin( RADIANS(xpd1.value ) ) + cos(0.632743928228) * cos( RADIANS(xpd1.value ) ) * cos( RADIANS(xpd2.value ) - -0.104081294481)) <= 0.0078480615288 
    ORDER BY distance ASC

    terraling
    Participant

    @terraling

    God bless WordPress (and google).

    Don’t suppose many people have heard of it, but there is a function wpautop() which wraps text sections in <p> tags to preserve linebreaks.

    Thanks for your input @henrywright


    terraling
    Participant

    @terraling

    No, even if I bypass BP completely and construct a direct SQL query to return the field I have the same problem.

    It’s not really a BP thing, it’s very basic and why I feel a bit sheep-ish asking. I might be better off asking on SO…


    terraling
    Participant

    @terraling

    Of course, I could just

    remove_filter( 'authenticate', 'bp_core_signup_disable_inactive', 30 );


    terraling
    Participant

    @terraling

    Okay, scratch that, it’s not working… I stripped out what I’d been tinkering with before.

    Here’s the problem:

    
    global $wpdb;
    // Activate user
    $wpdb->query('UPDATE wp_users SET user_status = 0 WHERE ID = '.$user_id);
    // Remove the activation key meta
    delete_user_meta( $user_id, 'activation_key' );
    //TESTING
    $user = get_user_by( 'id', $user_id );
    error_log("user id " . $user_id . " has status = " . $user->user_status);
    
    $signon = wp_signon( array('user_login' => $user_login, 'user_password' => $user_password, 'remember' => false) );
    

    So the signon fails because my error_log says
    user id 106 has status = 2
    even though it has just been set to 0 and, if I look directly in the wp_users table I see that it is indeed 0.

    I can only assume that the sql query to write user_status is slow and when I manually inspect it it has changed, but when the code checks it it is still set to 2.

    Does that sound plausible? Or am I missing something?


    terraling
    Participant

    @terraling

    Hmmm – it would seem so.

    Don’t know why but hooking onto the bp_screens action seems to have broken it, somehow, so I’ll need to rethink that, perhaps ask for a more appropriate hook to be added to core after all.

    Thanks @henrywright for the nudge.


    terraling
    Participant

    @terraling

    I figured out I could intercept it earlier.

    bp_core_screen_signup is loaded in the action bp_screens with a default priority of 10, so I added


    add_action( 'bp_screens', 'bp_core_screen_signup_tweak', 9 );
    function bp_core_screen_signup_tweak() {
    if ( isset( $_POST['signup_password'] ) ) {
    $_POST['signup_password_confirm'] = $_POST['signup_password'];
    }
    }


    terraling
    Participant

    @terraling

    Thanks @henrywright but you must not have read my question.

    I already did that, but need something server side in case javascript is unavailable on the client.


    terraling
    Participant

    @terraling

    It adds a wrapper with rel=”nofollow” in the link, and so I’ve searched for occurrences of that, but not found the right one.


    terraling
    Participant

    @terraling

    Thanks for the reply Henry, but it doesn’t happen in either global.js or buddypress-functions.php as far as I can tell.


    terraling
    Participant

    @terraling

    Mike

    WordPress and BuddyPress are set up to work in different languages provided the alternative language files are available and installed.

    There is a difference between running a site purely in another language, vs. having an existing site be able to switch between languages.

    If the site will be purely in Spanish that’s straightforward, you have to just load the WordPress and BuddyPress Spanish language files. If you want to switch that’s more complicated and you will want to use a plug-in to achieve that.

    If you are switching between languages, there’s the question of the WordPress & BuddyPress text (the buttons, things like “user1 posted an update 10 minutes ago” etc., and then there is your content, your words and the page, the menus etc.

    You’ve got a bit of reading to do to learn more about this.

    Start with https://codex.wordpress.org/WordPress_in_Your_Language

    For BuddyPress you can use this plug-in to make sure it loads the latest Spanish language files:
    https://wordpress.org/extend/plugins/buddypress-translations

    There are a bunch of plugins for maintaining a bilingual site that all work in different ways. Try WPML or qTranslate to get you started (although you may find they do not fully support BuddyPress, you’ll have to try them or contact the developers to see.)

    TL:DR; is it’s very straightforward for standalone sites in a different language, but pretty complex for multi-lingual sites that you can switch between languages.


    terraling
    Participant

    @terraling

    Case?

    John sends a friend request to Lucy.

    Lucy receives an email notification which invites her to check out John’s profile.

    When she does she sees a ‘Cancel Friendship Request’ button. She also sees how fond John is of gerbils and she quickly hits the button, but gets an error message ‘Friendship request cannot be cancelled’.

    She can’t cancel it because she didn’t initiate it.

    It seems logically there might be 3 options:

    1. she sees no button (likewise when John appears on the member directory list);
    2. she sees a button which takes her to her friend requests page where she can accept or reject it; or,
    3. she is able to accept/reject it then and there.

    These options become more user friendly but harder to implement.

    I would have thought 1. is, ahem, fairly straightforward, and wouldn’t break anything anywhere else.

    It would be helpful if check_is_friend in bp-friends-classes.php returned not just ‘pending’, ‘is_friend’, or ‘not_friends’ but differentiated ‘pending’ according to whether the current user had initiated it or not.

    But now I’m getting a little out of my depth…


    terraling
    Participant

    @terraling

    I’m trying to finesse this a little further and I’m hitting the bumpers, don’t know if you have any further insights @hnla or whether you’ve run out of patience with this one (understandable).

    One of the things I don’t like about how the friendship buttons work is that for pending it doesn’t differentiate who originated the request (although that is recorded in the bp_friends table in the db), so that the person who originated the request will see ‘Cancel friendship request’ when viewing the other’s profile, but vice versa, too. If the recipient of the request presses the button they get a ‘Friendship request cannot be cancelled’-type message, whereas it seems more appropriate that they shouldn’t see the button at all, or that it should be disabled.

    Hooking in to ‘bp_get_add_friend_button’ I have been able to alter $button as above, but I would like to be able to get in earlier (or reproduce the relevant part of bp-friends-template.php) to be able to add some logic for the case=’pending’ to check whether the current user was the initiator of the friendship request or not, and if they were the recipient of the request, disable the button.

    Any advice..? Thanks…


    terraling
    Participant

    @terraling

    Sorry @funmi-omoba, I didn’t quite get your question, but here is the code I added to my functions.php based on earlier answers:

    function my_add_friend_link_text($button) {
    	switch ( $button['id'] ) {
    		case 'pending' :
    			$button['link_text'] = 'x Pending';
    			$button['link_title'] = 'Cancel friend request';
    			$button['link_class'] .= ' btn btn-xs btn-warning';
    		break;
    
    		case 'is_friend' :
    			$button['link_text'] = '- Unfriend';
    			$button['link_class'] .= ' btn btn-xs btn-danger';
    		break;
    
    		default:
    			$button['link_text'] = '+ Friend';
    			$button['link_title'] = 'Send friend request';
    			$button['link_class'] .= ' btn btn-xs btn-success';
    	}
    	return $button;
    }
    add_filter('bp_get_add_friend_button', 'my_add_friend_link_text');
    

    I’m changing the link text, changing the title, and adding additional classes (I’m using bootstrap and wanted the buttons styled the same as elsewhere, though that means deleting the generic button styling from buddypress.css)

    Hope that helps.


    terraling
    Participant

    @terraling

    OK, simple now you point it out, thanks to you both…


    terraling
    Participant

    @terraling

    I’m pretty certain there is no way to avoid them having a username, although in principle you could auto-generate a string of random characters that they never see.

    I’m not familiar with the wordpress.com sign-up, but you could always pretty-please the Jetpack people to see if they will port it across to wordpress.org.

    Or look at the various social networking plug-ins. Social Login allows “your visitors to comment, log-in and register with their social network accounts” and works with WordPress and BuddyPress.

    If you want something more specific, then you may have to contract a developer to do it for you (then release it as a public plug-in!).


    terraling
    Participant

    @terraling

    WordPress requires a username which, once set, cannot be changed. People change email addresses, so an email address as username is not permitted.

    You can, though, use a plug-in called Email Login which lets users log in with their email address, so that they can use a username to register but then forget it and user their email address to access the site.


    terraling
    Participant

    @terraling

    Can’t hurt though, right?!

    Thanks for the tip, I’ll play around with it and if I encounter any issues I’ll revert to creating a translation file…


    terraling
    Participant

    @terraling

    Sorry, we seem to be talking at cross purposes. Adding body classes doesn’t do anything useful for me, I wanted to add classes to the html generated for the button, either add to wrapper_class or link_class above, and at the same time (more importantly) change the link_text from __( ‘Add Friend’, buddypress) to something else.

    I had hoped it would be as simple as reproducing the code from bp-friends-template.php in another location in my theme folder to overwrite the original, but from your replies it appears that such a thing is not possible.

    Thanks anyway for your help.


    terraling
    Participant

    @terraling

    Yeah, I just wanted to add some classes that I’m already using elsewhere in my theme if it’s straightforward to do, hence the question about whether it is possible to edit the bp-friends-template.php file.

    The answer to that is no, but can I override the above code somewhere else such as functions.php? If yes, an example of how would be really helpful.

    Thanks again…


    terraling
    Participant

    @terraling

    Taking a quick look at the bp-friends-template.php file it would also be able to change some other things, such as the class names that are added to the buttons, though it’s not a deal-breaker.

    				$button = array(
    					'id'                => 'not_friends',
    					'component'         => 'friends',
    					'must_be_logged_in' => true,
    					'block_self'        => true,
    					'wrapper_class'     => 'friendship-button not_friends',
    					'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    					'link_href'         => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ),
    					'link_text'         => __( 'Add Friend', 'buddypress' ),
    					'link_title'        => __( 'Add Friend', 'buddypress' ),
    					'link_id'           => 'friend-' . $potential_friend_id,
    					'link_rel'          => 'add',
    					'link_class'        => 'friendship-button not_friends add'
    				);
    

    terraling
    Participant

    @terraling

    In this instance I want to change the text for some of the buttons generated, e.g. the ‘Add Friend’ button etc.

    I know that one way to do it is to use a translation file, but that sort of seemed like overkill to just change a few small instances of text.

    But is that the recommended solution? I don’t mind dropping a function into my functions.php, although I may need a few pointers on how if it’s possible.

    Thanks for your feedback.


    terraling
    Participant

    @terraling

    On a user’s own profile page the class “my-account” is added to the body, so you can add a style to your CSS to hide it only on the profile page. E.g. if the element has the id=”agree-or-not”, then

    body.my-account #agree-or-not {display: none;}

    should do it.

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