bp_get_the_notification_delete_url

Return the URL used for deleting a single notification.

Description

(string) bp_get_the_notification_delete_url( (int) $user_id = 0 ); 

Returns (string)

Parameters (1)

0. $user_id — Optional. (int)
The user id.

Usage

  1. if ( !function_exists( 'bp_get_the_notification_delete_url' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-notifications/bp-notifications-template.php'; 
  3.  
  4. // The user id. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_get_the_notification_delete_url($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-notifications/bp-notifications-template.php  
  1. function bp_get_the_notification_delete_url( $user_id = 0 ) { 
  2. // Set default user ID to use. 
  3. $user_id = 0 === $user_id ? bp_displayed_user_id() : $user_id; 
  4.  
  5. // URL to add nonce to. 
  6. if ( bp_is_current_action( 'unread' ) ) { 
  7. } elseif ( bp_is_current_action( 'read' ) ) { 
  8. $link = bp_get_notifications_read_permalink( $user_id ); 
  9.  
  10. // Get the ID. 
  11.  
  12. // Get the args to add to the URL. 
  13. $args = array( 
  14. 'action' => 'delete',  
  15. 'notification_id' => $id 
  16. ); 
  17.  
  18. // Add the args. 
  19. $url = add_query_arg( $args, $link ); 
  20.  
  21. // Add the nonce. 
  22. $url = wp_nonce_url( $url, 'bp_notification_delete_' . $id ); 
  23.  
  24. /** 
  25. * Filters the URL used for deleting a single notification. 
  26. * @since 2.1.0 
  27. * @since 2.6.0 Added $user_id as a parameter. 
  28. * @param string $url URL used for deleting a single notification. 
  29. * @param int $user_id The user ID. 
  30. */