bp_legacy_theme_unmark_activity_favorite

Un-favourite an activity via a POST request.

Description

(string) bp_legacy_theme_unmark_activity_favorite(); 

Returns (string)

HTML


Usage

  1. if ( !function_exists( 'bp_legacy_theme_unmark_activity_favorite' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-templates/bp-legacy/buddypress-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bp_legacy_theme_unmark_activity_favorite(); 
  7.  

Defined (1)

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

/bp-templates/bp-legacy/buddypress-functions.php  
  1. function bp_legacy_theme_unmark_activity_favorite() { 
  2. // Bail if not a POST action. 
  3. if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) ) 
  4. return; 
  5.  
  6. if ( ! isset( $_POST['nonce'] ) ) { 
  7. return; 
  8.  
  9. // Either the 'mark' or 'unmark' nonce is accepted, for backward compatibility. 
  10. $nonce = wp_unslash( $_POST['nonce'] ); 
  11. if ( ! wp_verify_nonce( $nonce, 'mark_favorite' ) && ! wp_verify_nonce( $nonce, 'unmark_favorite' ) ) { 
  12. return; 
  13.  
  14. if ( bp_activity_remove_user_favorite( $_POST['id'] ) ) 
  15. _e( 'Favorite', buddypress ); 
  16. else 
  17. _e( 'Remove Favorite', buddypress ); 
  18.  
  19. exit;