1

Can someone help me with this?

This is supposed to go into functions.php:

function cg_current_user_notification_count() {
$notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object');
$count = !empty($notifications) ? count($notifications) : 0;

echo $count;
 }

In the templates where you want to show it.

<?php cg_current_user_notification_count(); ?>

Source: https://premium.wpmudev.org/forums/topic/add-buddypress-notifications-to-theme

The error I am getting is as follows, though:

fatal error: Uncaught Error: Call to undefined function bp_core_get_notifications_for_user() in /Applications/MAMP/htdocs/wp-content/themes/mytheme-child/functions.php:18 Stack trace: #0

Can someone help me with this? The function is not deprecated, so that can't be the issue...

What might be the problem here?

0

use this:

 
if ( !function_exists( 'bp_core_get_notifications_for_user' ) ) { 
    require_once '/wp-content/plugins/buddypress/bp-core/deprecated/1.9.php'; 
} 
function cg_current_user_notification_count() {
    $notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object');
    $count = !empty($notifications) ? count($notifications) : 0;

echo $count;}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.