function that breaks the BP AJAX
-
Hi guys! I have a WP 3.7.1 and BP 1.8.1 and I have created the following function in my functions.php to retrieve the number of notifications of the current user. The function has one parametrer $type_notification that can be: ‘new_message’, ‘group_invite’ or ‘friendship_request’.
The function works quite well, but the point is that with that function in functions.php, the BP ajax doesn’t work. For example: the search box in members or the members list pagination. If I delete this function from functions.php, the members pagination, etc. works fine again.
Does anyone know why is this happening? or an alternative function that I can use for this porpouse that doens’t break the ajax?
Thanks in advance! 🙂
RocÃo Valdivia
/** * Get notifications for a specific user */ function buddyboss_childtheme_core_get_notifications_for_user( $type_notification ) { global $bp; $user_id = $bp->loggedin_user->id; $notifications = BP_Core_Notification::get_all_for_user( $user_id ); $grouped_notifications = array(); // Notification groups $renderable = array(); // Renderable notifications // Group notifications by component and component_action and provide totals for ( $i = 0, $count = count( $notifications ); $i < $count; ++$i ) { $notification = $notifications[$i]; $grouped_notifications[$notification->component_name][$notification->component_action][] = $notification; } if($type_notification == 'new_message'): $number_notifications = count($grouped_notifications['messages']['new_message']); elseif($type_notification == 'group_invite'): $number_notifications = count($grouped_notifications['groups']['group_invite']); elseif($type_notification == 'friendship_request'): $number_notifications = count($grouped_notifications['friends']['friendship_request']); endif; return $number_notifications; }
- The topic ‘function that breaks the BP AJAX’ is closed to new replies.