Skip to:
Content
Pages
Categories
Search
Top
Bottom

Persistent Caching and Private Messaging


  • gregfielding
    Participant

    @gregfielding

    I’ve been wresting with an issue where memcached causes problems with buddypress private messaging and @mentions. Rather than try and bring back a old, confusing thread, I want to start fresh and clearly explain the issue.

    I’m using memcached. When I click to send a private message or @mentions, the wrong recipient shows up. This is a known issue that, supposedly, many of us who using persistent caching have. My confusion is in the fix.

    Trac ticket #2583 (http://trac.buddypress.org/ticket/2583) offers a patch, where you change a line in bp-messages-templatetags.php. This is easy to do, but it doesn’t fix the issue by itself. Further down the ticket, @r-a-y says:

    “With the patch, you’d still need to apply a filter to “bp_get_send_private_message_link” and override it so it doesn’t use bp_core_get_username().

    The same problem occurs with the bp_get_send_public_message_link() function – aka the “Mention this user” link.”

    I know just enough php to get myself into trouble and this is beyond me. Has anyone done this? Could anyone point me in the right direction for how to apply these filters?

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)

  • gregfielding
    Participant

    @gregfielding

    It looks like BP 1.3 is going to address some issues with object caching. https://trac.buddypress.org/ticket/2636

    Can anyone who knows confirm if it will fix these messaging issues?


    gregfielding
    Participant

    @gregfielding

    For anyone else with this issue, here is the fix. Thanks to @sbrajesh

    in bp-messages-templatetags.php, starting at line 498:

    function bp_send_private_message_link() {
    echo bp_get_send_private_message_link();
    }
    function bp_get_send_private_message_link() {
    global $bp;

    if ( bp_is_my_profile() || !is_user_logged_in() )
    return false;

    $user=new WP_User($bp->displayed_user->user_id);

    return apply_filters( ‘bp_get_send_private_message_link’, $bp->loggedin_user->domain . $bp->messages->slug . ‘/compose/?r=’ .$bp->displayed_user->userdata->user_login );
    }

    Private messaging now works with persistent caching like memcached.

    Thanks for the followup Greg. What is the exact change you made to the bp-messages-templatetags.php? Trying to figure out if it has already been updated in SVN.


    r-a-y
    Keymaster

    @r-a-y

    No need to hack BP.

    Put the following in your theme’s functions.php:

    `
    function ray_bp_get_send_public_message_link() {
    global $bp;

    return wp_nonce_url( $bp->loggedin_user->domain . $bp->activity->slug . ‘/?r=’ . $bp->displayed_user->userdata->user_login );
    }
    add_filter( ‘bp_get_send_public_message_link’, ‘ray_bp_get_send_public_message_link’ );

    function ray_bp_get_send_private_message_link() {
    global $bp;

    return wp_nonce_url( $bp->loggedin_user->domain . $bp->messages->slug . ‘/compose/?r=’ . $bp->displayed_user->userdata->user_login );
    }
    add_filter( ‘bp_get_send_private_message_link’, ‘ray_bp_get_send_private_message_link’ );`

    Thanks @r-a-y , I’ll give it a go.


    gregfielding
    Participant

    @gregfielding

    Thanks @r-a-y

    This is a better solution. Any thoughts on how to solve the same problem with @mentions?


    ds123
    Participant

    @ds123

    @gregfielding @r-a-y ….. thank you so much for bringing up this mentions issue …. i’m using w3tc latest versions of everything …i’ll keep checking back here for possible fix ….one other question lets say they fix the messaging issue in a future version of buddypress (and hopefully the @mentions) how would i know then to remove this from my functions.php file? would it be in the readme file of the latest version as an issue fixed in that release?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Persistent Caching and Private Messaging’ is closed to new replies.
Skip to toolbar