bpgifts_sendgift_updatedb

The Buddypress Gifts Latest 2014 bpgifts sendgift updatedb function.

Description

bpgifts_sendgift_updatedb(); 

Usage

  1. if ( !function_exists( 'bpgifts_sendgift_updatedb' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress-gifts-latest-2014/includes/bp-gifts-ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bpgifts_sendgift_updatedb(); 
  7.  

Defined (1)

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

/includes/bp-gifts-ajax.php  
  1. function bpgifts_sendgift_updatedb() { 
  2.  
  3. global $bp; 
  4.  
  5. if ( function_exists( 'cp_getPoints') ) { 
  6. $Mypoint = (int)cp_getPoints(cp_currentUser());  
  7. } elseif(function_exists( 'mycred' ) ) { 
  8. global $current_user; 
  9. get_currentuserinfo(); 
  10. //$user_id = bp_displayed_user_id(); 
  11. $user_id = $current_user->ID; 
  12. $mycred = mycred(); 
  13. $balance = $mycred->get_users_cred( $user_id ); 
  14. //echo 'Your balance is ' . $mycred->format_creds( $balance ); 
  15. $Mypoint = (int)$balance; 
  16. } else { 
  17. $Mypoint = 0; 
  18.  
  19. if($Mypoint < $_POST['point']) { 
  20. echo __('You dont have required points to send that Gift. You can choose another gift!', 'bp-gifts'); 
  21. exit; 
  22.  
  23. $action = __(bp_core_get_userlink($bp->loggedin_user->id).' '. __('send ', 'bp-gifts') . $_POST['gift_name'].' '. __('to ', 'bp-gifts') . bp_core_get_userlink($bp->displayed_user->id)); 
  24.  
  25.  
  26. $content = '<img class="gift-image" src="'. $_POST['gift_path'] .'" /><a href="'.$bp->displayed_user->domain.'">@'.$bp->displayed_user->userdata->user_login.'</a> '.$_POST['gift_message']; 
  27.  
  28. bp_gifts_record_activity( array( 'type' => 'new_gifts', 'action' => $action, 'user_id' => $bp->loggedin_user->id, 'item_id' => $bp->displayed_user->id, 'content' => $content) ); 
  29.  
  30.  
  31. echo __('Gifts was sent !'.'<br />', 'bp-gifts'); 
  32. echo __($_POST['point'].' Gift points deducted !', 'bp-gifts'); 
  33.  
  34. bp_gifts_send_giftsnotify( $bp->displayed_user->id, $bp->loggedin_user->id ); 
  35.  
  36.  
  37.  
  38. return false; 
  39.  
  40.  
  41.