Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress PM Message from Post

  • @klame

    Participant

    Hi,
    At my WordPress/Buddypress site users can create custom post.
    I want a “Write to the author” from the custom post- Using Buddypress message system.

    I came across this code:
    https://buddypress.org/support/topic/link-to-a-private-message/
    Which I put in functions.php.

    And it works fine.. Except the “Send To”.
    The author name dosent get passed through..

    The solution could be in this line:

    $compose_url.=('r=' . bp_core_get_username( $to_id ));

    I have tried to store a varible, and writing something like this:

    $compose_url.=('r='$authorname'' . bp_core_get_username( $to_id ));

    But I can’t get it right… Nothing really works.

    It only works when I write it manually like this:

    $compose_url.=('r=authorname' . bp_core_get_username( $to_id ));

    But that, of course, dosent really work for me..

    Have anybody success with sending a PM message from a post?
    Or have some idea what I could do, to get the author name / username in the “Send To”-Field.

Viewing 4 replies - 1 through 4 (of 4 total)
  • @donburikun

    Participant

    Did you ever find a solution to this? I too am looking to populate the Send To field on the PM compose page but have yet to find any solution.

    I found the below also:

    https://gist.github.com/digitalchild/02c0730deebb3e3fca68

    @koded1999

    Participant

    i am struggling with this as well. i used the code below in one of my sites and it populate the author automatically but doesnt on my second site, quite strange. any help pls will be appreciated

    function bpfr_message_shortcode() {	
    $author = get_the_author();
    $message = 'Login to contact advertiser!';
    
    if( is_user_logged_in() ) {
    	return '<a>MESSAGE ADVERTISER</a>';
     } else {
        return $message;
     }
    } 
    add_shortcode( 'ksam', 'bpfr_message_shortcode' );

    @koded1999

    Participant

    oops the html for removed. however, i managed to fix that and is working perfectly.

    but i have another problem.

    i will like to fill the subject automatically using the post title.

    pls how can i achieve this.

    thank you

    @danbp

    Participant

    Hi @koded1999,

    please, use the <code> button to insert snippets. Also avoid double posting.
    Closing this topic as duplicate.
    Conversation goes ahead here:

    Disable or Hide Private Message Button

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Buddypress PM Message from Post’ is closed to new replies.
Skip to toolbar