Skip to:
Content
Pages
Categories
Search
Top
Bottom

Using buddy press send message button 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 1 replies (of 1 total)

  • fuel2water
    Participant

    @fuel2water

    Hi @jawynan1, this exactly was I am looking for since ages. May I ask where you put the bp-custom-php file? I just registered within the site you are mentioning here, but I cant find the function to create a direkt message nor do I see a button on the listings page.

    It would be so much help for me, if you could give me a quick step by step overview. Just some info where you put the code above and if there is something else to modify.

    Also, may I ask what theme you are using? Looks like Listify, am I right?

    Thanks a million for your time!!

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