Hooks problem.
-
Hi There,
I am using the buddypress and apppresser plugin in our website. Apppresser plugin is used to convert wordpress web application to mobile application. I want to use buddypress hooks to send push notifications over the friend request and invite to group request trigger but this is not working. I am using the following hooks for the same
groups_send_invites
groups_accept_invite
friends_friendship_accepted
bp_activity_add_user_favorite
friends_friendship_requestedHere is my code which I have written on function.php .
function action_groups_send_invite( $group_id, $invited_users, $user_id ) {
// make action magic happen here…
if ( !is_user_logged_in() )
return false;
$message = ‘Hi there some one send your request!’;$push = new AppPresser_Notifications_Update;
$devices = $push->get_devices_by_user_id($invited_users);
if( $devices ) {
$push->notification_send( ‘now’, $message, 1, $devices );
}
};// add the action
add_action( ‘groups_send_invites’, ‘action_groups_send_invite’, 10, 3 );function action_friends_friendship_requested( $friendship_id, $initiator_id, $friend_id ) {
if ( !is_user_logged_in() )
return false;$recipients = array( $initiator_id );
$message = ‘Hi there some one send you request!’;
$push = new AppPresser_Notifications_Update;
$devices = $push->get_devices_by_user_id( $recipients );if( $devices ) {
$push->notification_send( ‘now’, $message, 1, $devices );
}//apppush_send_notification( ‘friends_friendship_requested’ );
};// add the action
add_action( “friends_friendship_requested”, ‘action_friends_friendship_requested’, 10, 4 );function action_friends_friendship_accepted( $friendship_id, $friendship_initiator_user_id, $friendship_friend_user_id, $friendship ) {
// // make action magic happen here…
if ( !is_user_logged_in() )
return false;$recipients = array( $friendship_initiator_user_id );
$message = ‘Hi there some one accept your request!’;
$push = new AppPresser_Notifications_Update;
$devices = $push->get_devices_by_user_id( $recipients );if( $devices ) {
$push->notification_send( ‘now’, $message, 1, $devices );
}
//apppush_send_notification( ‘friends_friendship_accepted’ );
};// add the action
add_action( ‘friends_friendship_accepted’, ‘action_friends_friendship_accepted’, 10, 4 );function action_add_user_favorite( $activity_id, $user_id ) {
// do something$recipients = array( $user_id );
$message = ‘Hi there some one accept your friend request!’;
$push = new AppPresser_Notifications_Update;
$devices = $push->get_devices_by_user_id( $recipients );if( $devices ) {
$push->notification_send( ‘now’, $message, 1, $devices );
}
}
add_action(‘bp_activity_add_user_favorite’, ‘action_add_user_favorite’, 1, 2 );
- You must be logged in to reply to this topic.