title: How to fix fatal error in wpmudev private messaging wordpress plugins
body: <p>How I can fix this:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function is_lock() on a non-object in
    /home/u791507189/public_html/wp-content/plugins/private-messaging/app/views/shortcode/_inbox_message.php
    on line 12</p>
  </blockquote>
  
  <p>Here is code:</p>
  
  <pre><code>&lt;?php
  $message = array_shift($messages);
  if (!isset($render_reply)) {
      $render_reply = true;
  }
  $conversation = MM_Conversation_Model::model()-&gt;find($message-&gt;conversation_id);
  ?&gt;
  &lt;div class="ig-container"&gt;
      &lt;section class="message-content"&gt;
          &lt;div class="message-content-meta pull-left"&gt;
              &lt;?php do_action('message_content_meta', $message) ?&gt;
              &lt;?php if ($conversation-&gt;is_lock()): ?&gt; ***/////&lt;----here is error////////***
                  &lt;div class="clearfix"&gt;&lt;/div&gt;
                  &lt;span&gt;&lt;?php _e("This conversation has been locked", mmg()-&gt;domain) ?&gt;&lt;/span&gt;
              &lt;?php endif; ?&gt;
          &lt;/div&gt;
          &lt;div class="message-content-actions pull-right"&gt;
              &lt;?php if (mmg()-&gt;get('box') != 'sent' &amp;&amp; $render_reply == true): ?&gt;
                  &lt;?php
                  $from_data = get_userdata($message-&gt;send_from);
                  ?&gt;
                  &lt;div class="btn-group btn-group-sm"&gt;
                      &lt;?php if ($conversation-&gt;is_archive()): ?&gt;
                          &lt;a href="#" title="&lt;?php echo esc_attr(__("Unarchive", mmg()-&gt;domain)) ?&gt;"
                             data-id="&lt;?php echo esc_attr(mmg()-&gt;encrypt($message-&gt;conversation_id)) ?&gt;"
                             data-type="&lt;?php echo MM_Message_Status_Model::STATUS_READ ?&gt;"
                             class="btn btn-sm btn-default mm-status"&gt;&lt;i class="fa fa-undo"&gt;&lt;/i&gt;&lt;/a&gt;
                          &lt;a href="#" title="&lt;?php echo esc_attr(__("Delete", mmg()-&gt;domain)) ?&gt;"
                             data-id="&lt;?php echo esc_attr(mmg()-&gt;encrypt($message-&gt;conversation_id)) ?&gt;"
                             data-type="&lt;?php echo MM_Message_Status_Model::STATUS_DELETE ?&gt;"
                             class="btn btn-sm btn-danger mm-status"&gt;&lt;i class="fa fa-trash"&gt;&lt;/i&gt;&lt;/a&gt;
                      &lt;?php else: ?&gt;
                          &lt;?php if ($conversation-&gt;is_lock()): ?&gt;
                              &lt;button type="button" class="btn btn-info btn-sm" disabled&gt;
                                  &lt;i class="fa fa-reply"&gt;&lt;/i&gt;
                              &lt;/button&gt;
                          &lt;?php else: ?&gt;
                              &lt;a href="#reply-form-c"
                                 data-username="&lt;?php echo esc_attr($from_data-&gt;user_login) ?&gt;"
                                 data-parentid="&lt;?php echo esc_attr(mmg()-&gt;encrypt($message-&gt;conversation_id)) ?&gt;"
                                 data-id="&lt;?php echo esc_attr(mmg()-&gt;encrypt($message-&gt;id)) ?&gt;" type="button"
                                 class="btn btn-info btn-sm mm-reply"&gt;
                                  &lt;i class="fa fa-reply"&gt;&lt;/i&gt;
                              &lt;/a&gt;
                          &lt;?php endif; ?&gt;
                          &lt;a href="#" title="&lt;?php echo esc_attr(__("Archive", mmg()-&gt;domain)) ?&gt;"
                             data-id="&lt;?php echo esc_attr(mmg()-&gt;encrypt($message-&gt;conversation_id)) ?&gt;"
                             data-type="&lt;?php echo MM_Message_Status_Model::STATUS_ARCHIVE ?&gt;"
                             class="btn btn-sm btn-default mm-status"&gt;&lt;i class="fa fa-archive"&gt;&lt;/i&gt;&lt;/a&gt;
                      &lt;?php endif; ?&gt;
                  &lt;/div&gt;
              &lt;?php endif; ?&gt;
              &lt;!--&lt;button type="button" class="btn btn-danger btn-sm"&gt;
                  &lt;i class="glyphicon glyphicon-trash"&gt;&lt;/i&gt;
              &lt;/button&gt;--&gt;
          &lt;/div&gt;
          &lt;?php /*$this-&gt;render_partial('shortcode/_reply_form', array(
              'message' =&gt; $message
          )); */ ?&gt;
          &lt;div class="clearfix"&gt;&lt;/div&gt;
          &lt;div class="page-header"&gt;
              &lt;h3 class="mm-message-subject"&gt;&lt;?php echo apply_filters('mm_message_subject', $message-&gt;subject) ?&gt;&lt;/h3&gt;
  
              &lt;div class="row"&gt;
                  &lt;div class="col-md-12"&gt;
                      &lt;div class="row"&gt;
                          &lt;div class="col-md-3"&gt;
                              &lt;img style="width: 100%;max-width: 100px" class="img-responsive img-circle center-block"
                                   src="&lt;?php echo mmg()-&gt;get_avatar_url(get_avatar($message-&gt;send_from)) ?&gt;"&gt;
                          &lt;/div&gt;
                          &lt;div class="col-md-9"&gt;
                              &lt;strong&gt;&lt;?php
                                  if ($message-&gt;send_from == get_current_user_id()) {
                                      echo __("me", mmg()-&gt;domain) . ' (' . $message-&gt;get_name($message-&gt;send_from) . ')';
                                  } else {
                                      echo $message-&gt;get_name($message-&gt;send_from);
                                  } ?&gt;&lt;/strong&gt;
  
                              &lt;div class="clearfix"&gt;&lt;/div&gt;
                              &lt;span&gt;&lt;?php echo date('F j, Y, g:i a', strtotime($message-&gt;date)) ?&gt;&lt;/span&gt;
  
                              &lt;div class="clearfix"&gt;&lt;/div&gt;
                              &lt;?php if (mmg()-&gt;get('box') == 'sent'): ?&gt;
                                  &lt;small&gt;&lt;?php _e("To:", mmg()-&gt;domain) ?&gt; &lt;?php echo $message-&gt;get_name($message-&gt;send_to); ?&gt;&lt;/small&gt;
                              &lt;?php endif; ?&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="clearfix"&gt;&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="message-body"&gt;
              &lt;?php echo mmg()-&gt;html_beautifier(apply_filters('mm_message_content', $message-&gt;content)) ?&gt;
          &lt;/div&gt;
          &lt;?php $ids = explode(',', $message-&gt;attachment);
          $ids = array_filter($ids);
          if (count($ids)):?&gt;
              &lt;hr/&gt;
              &lt;div class="message-footer"&gt;
                  &lt;div class="row"&gt;
                      &lt;?php foreach ($ids as $id): ?&gt;
                          &lt;?php $a_m = IG_Uploader_Model::model()-&gt;find($id); ?&gt;
                          &lt;div class="col-md-6 message-attachment"&gt;
                              &lt;a class="load-attachment-info" data-target="&lt;?php echo $id ?&gt;" href="#"&gt;
                                  &lt;i class="fa fa-paperclip fa-2x pull-left"&gt;&lt;/i&gt;
                                  &lt;?php echo $a_m-&gt;name ?&gt; &lt;/a&gt;
  
                              &lt;div class="clearfix"&gt;&lt;/div&gt;
                              &lt;!-- Modal --&gt;
                              &lt;div class="modal" data-id="&lt;?php echo $id ?&gt;"&gt;
                                  &lt;div class="modal-dialog"&gt;
                                      &lt;div class="modal-content"&gt;
                                          &lt;div class="modal-header"&gt;
                                              &lt;h4 class="modal-title"&gt;&lt;?php echo $a_m-&gt;name ?&gt;&lt;/h4&gt;
                                          &lt;/div&gt;
                                          &lt;div class="modal-body sample-pop" style="max-height:450px;overflow-y:scroll"&gt;
                                              &lt;?php
                                              $file = $a_m-&gt;file;
                                              //check does this file exist
  
                                              $file_url = '';
                                              $show_image = false;
  
                                              if ($file) {
                                                  $file_url = wp_get_attachment_url($file);
                                                  $mime = explode('/', get_post_mime_type($file));
                                                  if (array_shift($mime) == 'image') {
                                                      $show_image = true;
                                                  }
                                              }
                                              if ($show_image) {
                                                  echo '&lt;img src="' . $file_url . '"/&gt;';
                                              } elseif ($file) {
                                                  //show meta
                                                  ?&gt;
                                                  &lt;ul class="list-group"&gt;
                                                      &lt;li class="list-group-item upload-item"&gt;
                                                          &lt;i class="glyphicon glyphicon-floppy-disk"&gt;&lt;/i&gt;
                                                          &lt;?php _e('Size', mmg()-&gt;domain) ?&gt;:
                                                          &lt;strong&gt;&lt;?php
                                                              $tfile = get_attached_file($file);
                                                              //check does this files has deleted
                                                              if ($tfile) {
                                                                  $size = @filesize($tfile);
                                                                  echo $size === false ? 'N/A' : $size;
                                                              } else {
                                                                  echo __("N/A", mmg()-&gt;domain);
                                                              }
                                                              ?&gt;&lt;/strong&gt;
                                                      &lt;/li&gt;
                                                      &lt;li class="list-group-item upload-item"&gt;
                                                          &lt;i class="glyphicon glyphicon-file"&gt;&lt;/i&gt;
                                                          &lt;?php _e('Type', mmg()-&gt;domain) ?&gt;:
                                                          &lt;strong&gt;&lt;?php echo ucwords(get_post_mime_type($file)) ?&gt;&lt;/strong&gt;
                                                      &lt;/li&gt;
                                                  &lt;/ul&gt;
                                              &lt;?php
                                              } else {
                                                  ?&gt;
                                                  &lt;ul class="list-group"&gt;
                                                      &lt;li class="list-group-item"&gt;
                                                          &lt;i class="glyphicon glyphicon-link"&gt;&lt;/i&gt;
                                                          &lt;strong&gt;&lt;?php _e('Link', mmg()-&gt;domain) ?&gt;&lt;/strong&gt;:
                                                          &lt;?php echo $a_m-&gt;url ?&gt;
                                                      &lt;/li&gt;
                                                      &lt;div class="clearfix"&gt;&lt;/div&gt;
                                                  &lt;/ul&gt;
                                              &lt;?php
                                              } ?&gt;
                                          &lt;/div&gt;
                                          &lt;div class="modal-footer"&gt;
                                              &lt;?php if ($a_m-&gt;url): ?&gt;
                                                  &lt;a class="btn btn-info" rel="nofollow"
                                                     href="&lt;?php echo esc_attr($a_m-&gt;url) ?&gt;" target="_blank"&gt;
                                                      &lt;?php _e("Visit Link", mmg()-&gt;domain) ?&gt;
                                                  &lt;/a&gt;
                                              &lt;?php endif; ?&gt;
                                              &lt;?php if ($a_m-&gt;file): ?&gt;
                                                  &lt;a href="&lt;?php echo $file_url ?&gt;" download
                                                     class="btn btn-info"&gt;&lt;?php _e('Download File', mmg()-&gt;domain) ?&gt;&lt;/a&gt;
                                              &lt;?php endif; ?&gt;
                                              &lt;button type="button" class="btn btn-default attachment-close"
                                                      data-dismiss="modal"&gt;Close
                                              &lt;/button&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;?php endforeach; ?&gt;
                      &lt;div class="clearfix"&gt;&lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;?php endif; ?&gt;
      &lt;/section&gt;
      &lt;!--render history--&gt;
      &lt;?php if (is_array($messages) &amp;&amp; count($messages)): ?&gt;
          &lt;div class="well well-sm no-margin"&gt;
              &lt;?php foreach ($messages as $key =&gt; $message): ?&gt;
                  &lt;section class="message-content"&gt;
  
                      &lt;div class="page-header"&gt;
                          &lt;h3 class="mm-message-subject"&gt;&lt;?php echo apply_filters('mm_message_subject', $message-&gt;subject) ?&gt;&lt;/h3&gt;
  
                          &lt;div class="row"&gt;
                              &lt;div class="col-md-12"&gt;
                                  &lt;div class="row"&gt;
                                      &lt;div class="col-md-3"&gt;
                                          &lt;img style="max-width:100px;width: 100%"
                                               class="img-responsive img-circle center-block"
                                               src="&lt;?php echo mmg()-&gt;get_avatar_url(get_avatar($message-&gt;send_from)) ?&gt;"&gt;
                                      &lt;/div&gt;
                                      &lt;div class="col-md-9"&gt;
                                          &lt;strong&gt;&lt;?php echo $message-&gt;get_name($message-&gt;send_from) ?&gt;&lt;/strong&gt;
  
                                          &lt;div class="clearfix"&gt;&lt;/div&gt;
                                          &lt;span&gt;&lt;?php echo date('F j, Y, g:i a', strtotime($message-&gt;date)) ?&gt;&lt;/span&gt;
  
                                          &lt;div class="clearfix"&gt;&lt;/div&gt;
                                          &lt;?php if (mmg()-&gt;get('box') == 'sent'): ?&gt;
                                              &lt;small&gt;&lt;?php _e("To:", mmg()-&gt;domain) ?&gt; &lt;?php echo $message-&gt;get_name($message-&gt;send_to) ?&gt;&lt;/small&gt;
                                          &lt;?php endif; ?&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="clearfix"&gt;&lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="message-body"&gt;
                          &lt;?php echo mmg()-&gt;html_beautifier(apply_filters('mm_message_content', $message-&gt;content)) ?&gt;
                      &lt;/div&gt;
                      &lt;?php $ids = explode(',', $message-&gt;attachment);
                      $ids = array_filter($ids);
                      if (count($ids)):?&gt;
                          &lt;hr/&gt;
                          &lt;div class="message-footer"&gt;
                              &lt;div class="row"&gt;
                                  &lt;?php foreach ($ids as $id): ?&gt;
                                      &lt;?php $a_m = IG_Uploader_Model::model()-&gt;find($id); ?&gt;
                                      &lt;div class="col-md-6 message-attachment"&gt;
                                          &lt;a class="load-attachment-info" data-target="&lt;?php echo $id ?&gt;" href="#"&gt;
                                              &lt;i class="fa fa-paperclip fa-2x pull-left"&gt;&lt;/i&gt;
                                              &lt;?php echo $a_m-&gt;name ?&gt; &lt;/a&gt;
  
                                          &lt;div class="clearfix"&gt;&lt;/div&gt;
                                          &lt;!-- Modal --&gt;
                                          &lt;div class="modal" data-id="&lt;?php echo $id ?&gt;"&gt;
                                              &lt;div class="modal-dialog"&gt;
                                                  &lt;div class="modal-content"&gt;
                                                      &lt;div class="modal-header"&gt;
                                                          &lt;h4 class="modal-title"&gt;&lt;?php echo $a_m-&gt;name ?&gt;&lt;/h4&gt;
                                                      &lt;/div&gt;
                                                      &lt;div class="modal-body sample-pop"
                                                           style="max-height:450px;overflow-y:scroll"&gt;
                                                          &lt;?php
                                                          $file = $a_m-&gt;file;
                                                          //check does this file exist
  
                                                          $file_url = '';
                                                          $show_image = false;
  
                                                          if ($file) {
                                                              $file_url = wp_get_attachment_url($file);
                                                              $mime = explode('/', get_post_mime_type($file));
                                                              if (array_shift($mime) == 'image') {
                                                                  $show_image = true;
                                                              }
                                                          }
                                                          if ($show_image) {
                                                              echo '&lt;img src="' . $file_url . '"/&gt;';
                                                          } elseif ($file) {
                                                              //show meta
                                                              ?&gt;
                                                              &lt;ul class="list-group"&gt;
                                                                  &lt;li class="list-group-item upload-item"&gt;
                                                                      &lt;i class="glyphicon glyphicon-floppy-disk"&gt;&lt;/i&gt;
                                                                      &lt;?php _e('Size', mmg()-&gt;domain) ?&gt;:
                                                                      &lt;strong&gt;&lt;?php
                                                                          $tfile = get_attached_file($file);
                                                                          //check does this files has deleted
                                                                          if ($tfile) {
                                                                              $size = @filesize($tfile);
                                                                              echo $size === false ? 'N/A' : $size;
                                                                          } else {
                                                                              echo __("N/A", mmg()-&gt;domain);
                                                                          }
                                                                          ?&gt;&lt;/strong&gt;
                                                                  &lt;/li&gt;
                                                                  &lt;li class="list-group-item upload-item"&gt;
                                                                      &lt;i class="glyphicon glyphicon-file"&gt;&lt;/i&gt;
                                                                      &lt;?php _e('Type', mmg()-&gt;domain) ?&gt;:
                                                                      &lt;strong&gt;&lt;?php echo ucwords(get_post_mime_type($file)) ?&gt;&lt;/strong&gt;
                                                                  &lt;/li&gt;
                                                              &lt;/ul&gt;
                                                          &lt;?php
                                                          } else {
                                                              ?&gt;
                                                              &lt;ul class="list-group"&gt;
                                                                  &lt;li class="list-group-item"&gt;
                                                                      &lt;i class="glyphicon glyphicon-link"&gt;&lt;/i&gt;
                                                                      &lt;strong&gt;&lt;?php _e('Link', mmg()-&gt;domain) ?&gt;&lt;/strong&gt;:
                                                                      &lt;?php echo $a_m-&gt;url ?&gt;
                                                                  &lt;/li&gt;
                                                                  &lt;div class="clearfix"&gt;&lt;/div&gt;
                                                              &lt;/ul&gt;
                                                          &lt;?php
                                                          } ?&gt;
                                                      &lt;/div&gt;
                                                      &lt;div class="modal-footer"&gt;
                                                          &lt;?php if ($a_m-&gt;url): ?&gt;
                                                              &lt;a class="btn btn-info" rel="nofollow"
                                                                 href="&lt;?php echo esc_attr($a_m-&gt;url) ?&gt;" target="_blank"&gt;
                                                                  &lt;?php _e("Visit Link", mmg()-&gt;domain) ?&gt;
                                                              &lt;/a&gt;
                                                          &lt;?php endif; ?&gt;
                                                          &lt;?php if ($a_m-&gt;file): ?&gt;
                                                              &lt;a href="&lt;?php echo $file_url ?&gt;" download
                                                                 class="btn btn-info"&gt;&lt;?php _e('Download File', mmg()-&gt;domain) ?&gt;&lt;/a&gt;
                                                          &lt;?php endif; ?&gt;
                                                          &lt;button type="button" class="btn btn-default attachment-close"
                                                                  data-dismiss="modal"&gt;Close
                                                          &lt;/button&gt;
                                                      &lt;/div&gt;
                                                  &lt;/div&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;?php endforeach; ?&gt;
                                  &lt;div class="clearfix"&gt;&lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;?php endif; ?&gt;
                  &lt;/section&gt;
              &lt;?php endforeach; ?&gt;
          &lt;/div&gt;
      &lt;?php endif; ?&gt;
  &lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
      jQuery(document).ready(function ($) {
          $('.mm-reply').leanModal({
              closeButton: ".compose-close",
              top: '5%',
              width: '90%',
              maxWidth: 659
          });
          /*$('.load-attachment-info').leanModal({
           closeButton: '.attachment-close',
           top: '5%',
           width: '90%',
           maxWidth: 659
           });*/
      })
  &lt;/script&gt;
  </code></pre>