Skip to:
Content
Pages
Categories
Search
Top
Bottom

php fatal error $message->send()

  • @garprogram

    Participant

    Hello everyone, thanks in advance.

    I’m trying to filter messages through ‘messages_message_before_save’ action hook.
    When the test is positive, I remove the recipient with unset.
    If I have no recipients I get a php error.

    [22-Nov-2015 14:25:22 UTC] PHP Fatal error: Call to a member function get_error_message() on a non-object in xxxxxxxxxxxxxx/wp-content/plugins/buddypress/bp-messages/bp-messages-actions.php on line 104

    .....bp-messages-actions.php.........
     .................................
    // Message could not be sent.
     } else {
        $success  = false;
        $feedback = $send->get_error_message();  //LINE 104 bp-messages-actions.php
     }

    It’s because I have not created an error message.
    I tried with:

    bp_core_add_message( 'Message error.', 'error' );

    but don’t works.

    How can i fix this?

    This is my code.

    function messages_control($args){
     if(!is_super_admin()){
       foreach($args->recipients as $key => $value){
         $receiver = $value->user_id;
         if( $receiver === X ){    // X is an integer
           error_log('MESSAGE UNSET');
           unset($args->recipients[$key]);
         } 
        }
        if(empty($args->recipients)){
          bp_core_add_message( 'Message error.', 'error' );  // ????????
        }
     }
    }
    add_action('messages_message_before_save','messages_control',10,1);

    Thanks in advance. Sorry for my english…..

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘php fatal error $message->send()’ is closed to new replies.
Skip to toolbar