‘meta’ field on messages | WordPress.org

Hello,
Thank you again for the added hooks.

I’ve noticed the message objects appear with the field ‘meta’ always empty when I use the new hook:


      wp.hooks.addFilter('better_messages_single_message_class', 'custom_action', function (classes, message) {
            console.log( message ); // Here you can get message object
        
            classes += ' msg-custom';
            return classes; // Processing to default click event
        })

I’m sending a message programmatically like this:

$args = array(
			'sender_id'  => $sender_id,
			'thread_id'  => $thread_id['thread_id'],
			'recipients' => $recipient_id,
			'subject'    => '',
			'content'    => '<span class="donation-msg">' . $message . '</span>', //'<span class="donation_client">(' . $amount. ')</span><span class="donation_subs">(' . $share. '€)</span>',
			'meta'		 => array('donation'),
			'meta_data'	 => array('donation' => abs($amount)),
			'date_sent'  => bp_core_current_time(),
			'return'	 => 'message_id'
		);

$message_id = Better_Messages_Functions()->new_message( $args );

I see that in the public function new_message in ./inc/functions.php, it is creating the object BM_Messages_Message and then setting its ‘meta’ field to the one in $args passed to the function: $message->meta = $r['meta'];. However, I’m not seeing this field declared inside the BM_Messages_Message class.

Maybe the reason the field ‘meta’ comes out always empty in the browser console, is because it’s not declared yet in the BM_Messages_Message class?

Thank you.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer