[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-messages/actions/ -> delete.php (source)

   1  <?php
   2  /**
   3   * Messages: Delete action handler.
   4   *
   5   * @package BuddyPress
   6   * @subpackage MessageActions
   7   * @since 3.0.0
   8   */
   9  
  10  /**
  11   * Process a request to delete a message.
  12   *
  13   * @return bool False on failure.
  14   */
  15  function messages_action_delete_message() {
  16  
  17      if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'delete', 0 ) ) {
  18          return false;
  19      }
  20  
  21      $thread_id = bp_action_variable( 1 );
  22  
  23      if ( ! $thread_id || ! is_numeric( $thread_id ) || ! messages_check_thread_access( $thread_id ) ) {
  24          bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ) );
  25      } else {
  26          if ( ! check_admin_referer( 'messages_delete_thread' ) ) {
  27              return false;
  28          }
  29  
  30          // Delete message.
  31          if ( ! messages_delete_thread( $thread_id ) ) {
  32              bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
  33          } else {
  34              bp_core_add_message( __('Message deleted.', 'buddypress') );
  35          }
  36          bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ) );
  37      }
  38  }
  39  add_action( 'bp_actions', 'messages_action_delete_message' );


Generated: Thu Dec 26 01:01:04 2024 Cross-referenced by PHPXref 0.7.1