Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create BP_Messages_Message object


  • abhimanyubind
    Participant

    @abhimanyubind

    Hello, I am trying to create object of ‘BP_Messages_Message’ to get the recipients. I tried the following code on ‘messages_message_after_save’ hook:

    $message = new BP_Messages_Message;
    print_r($message);

    from the above code I am getting the following results:

    BP_Messages_Message Object ( [id] => [thread_id] => [sender_id] => 1 [subject] => [message] => [date_sent] => 2015-02-16 07:10:20 [recipients] => ).

    Why am I getting blank values in other fields ? Do I need pass any parameters while creating the object?

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

  • danbp
    Moderator

    @danbp

    hi @abhimanyubind,

    i’m not developer, but i think th e answer is yes.

    For example, to allow admin to receive a copy of messages sent by users

    function arc_wp_mail_filter( $args ) {
    	
            $args['headers'] = 'Bcc: <admin@yoursite.com>'; 
    
    	$new_wp_mail = array(
    		'to'          => $args['to'],
    		'subject'     => $args['subject'],
    		'message'     => $args['message'],
    		'headers'     => $args['headers'],
    		'attachments' => $args['attachments']
    	);
    	
    	return $new_wp_mail;
    }
    add_filter( 'wp_mail', 'arc_wp_mail_filter' );

    Here an old topic with a similar question and answered by our core ninja’s.

    Hope this will help you !


    Henry Wright
    Moderator

    @henrywright

    Hi @abhimanyubind

    You’re getting blank values because your code $message = new BP_Messages_Message; will create a brand new object. Hence, sender ID, date sent etc haven’t been populated with any data yet


    abhimanyubind
    Participant

    @abhimanyubind

    Hi @Henry Wright

    How can I get those values by creating object of BP_Messages_Message OR which method can be used to get the current thread id. I had tried number of attempts but was unable to get the result.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create BP_Messages_Message object’ is closed to new replies.
Skip to toolbar