Skip to:
Content
Pages
Categories
Search
Top
Bottom

Linking buddy press new message as a link on a listings page.


  • jawynan1
    Participant

    @jawynan1

    WordPress Version 4.4.3
    BuddPress Version 2.4.3

    link – http://dev.inclusivetech.net/hammydowns/
    Although you need to be logged in to see the button on the listings page.

    Ok so obviously I have researched this matter on these forums before and have found useful
    advice that i have used to make the button work. The one issue I am having trouble with
    is pre-filling the messages subject field with the title of the item they wish to
    message the user about.
    The link works well and the user(Send To) field that the message is being sent to is correctly filled in after clicking on the button to message that person, similar to visiting a members profile page and then clicking private message.

    I created the bp-custom.php file to achieve putting the link on the listings page. The code in there is as follows:

    function bp_custom_get_send_private_message_link($to_id,$subject=false,$message=false) {
    
    //if user is not logged, do not prepare the link
    if ( !is_user_logged_in() )
    return false;
    
    $compose_url=bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?';
    if($to_id)
    $compose_url.=('r=' . bp_core_get_username( $to_id ));
    if($subject) 
    $compose_url.=('&subject='.$subject);
    /*if($message)
    $compose_url.=("&content=".$message);*/
    
    return wp_nonce_url( $compose_url ) ;
    }
    
    //for auto populating message content
    add_filter(‘bp_get_messages_content_value’,’bp_custom_message_content_value’);
    function bp_custom_message_content_value($content){
    
    if(!empty ($content))
    return $content;
    $content=$_REQUEST[‘content’];
    
    return $content;
    }
    

    Again this works well but for some reason this line of code does not seem to be effecting my messages
    subject field at all. $compose_url.=('&subject='.$subject);

    I am calling the function correctly and the resulting http address is http://dev.inclusivetech.net/hammydowns/members/admin/messages/compose/?r=tvolmari&subject=Leather+Wallet&_wpnonce=181a9404ae
    so I can see the subject title is being passed but it won’t populate my messages subject field.

    Does anyone have any possible advice on how to solve this??? Or maybe a least a new direction
    I should start to look at to figure it out? I’m starting to run out of idea’s.. haha

    Any help would be appreciated thx 🙂

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

  • danbp
    Moderator

    @danbp

    Please use code buton when you paste code in a topic. Thxs.


    jawynan1
    Participant

    @jawynan1

    function bp_custom_get_send_private_message_link($to_id,$subject=false,$message=false) {
    
    //if user is not logged, do not prepare the link
    if ( !is_user_logged_in() )
    return false;
    
    $compose_url=bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?';
    if($to_id)
    $compose_url.=('r=' . bp_core_get_username( $to_id ));
    if($subject) 
    $compose_url.=('&subject='.$subject);
    /*if($message)
    $compose_url.=("&content=".$message);*/
    
    return wp_nonce_url( $compose_url ) ;
    }
    
    //for auto populating message content
    add_filter(‘bp_get_messages_content_value’,’bp_custom_message_content_value’);
    function bp_custom_message_content_value($content){
    
    if(!empty ($content))
    return $content;
    $content=$_REQUEST[‘content’];
    
    return $content;
    }

    jawynan1
    Participant

    @jawynan1

    ok done, sorry about that


    helgipetersen
    Participant

    @helgipetersen

    Any update with this ?

    I have the same problem. Have added “&content=meessagetitle” at the end of the url.
    But the subjects is empty


    ali
    Participant

    @kusatra

    Any development on this issue. I do have the same problem.
    http://www.site.com/members/user/messages/compose/?r=test1&subject=zxcxzxc
    This does not work.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar