I am new in wordpress development and I want to start to develop a personal plugin which will i use in my site. my site uses wordpress and buddypress. In buddypress, they have notifications, which is pretty good. but i want my plugin to also add notifications to buddypress as well, and will appear to members.
I have seen the documentation here: bp_notifications_add_notification()
so far my code is below. Please note that i have removed may parts of the plugin just to simplify it
<?php
/*
Plugin Name: Test
Description: personal plugin for my site
Version: 1.0.0
*/
function sample_add_notification( $u_id ) {
$args = array(
'user_id' => $u_id
);
bp_notifications_add_notification( $args );
}
sample_add_notification( 2 ); //this line should write a new notification for user_id: 2
?>
but when ever I run it. it says:
Fatal error: Call to undefined function bp_notifications_add_notification() in C:\xampp\htdocs\htbcph\wp-content\plugins\test\test-plugin.php on line 14
i think the problem is, i need to include the component first. but how will i do it? please provide me links for good tutorials that will help me. Thanks