Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable notifications doesn't work #46

Open
andrei90vs opened this issue Jan 27, 2016 · 8 comments
Open

Enable notifications doesn't work #46

andrei90vs opened this issue Jan 27, 2016 · 8 comments

Comments

@andrei90vs
Copy link

Hi , I tried to use this option but doesn't work and I have installed BuddyPress Live Notification, do you know how can I use both of them ? thx.

@gceluque
Copy link

gceluque commented Apr 6, 2016

@andrei90vs same issue here.
Tried soooo many solutions and cannot believe how such functionality isnt part of core.
Did you find any work around @andrei90vs ?
Cheers

@andrei90vs
Copy link
Author

No ... I used existing notification and I positioned where I wanted.

@gceluque
Copy link

gceluque commented Apr 6, 2016

oh ok... I'm still trying to figure out a way of having all notifications consistent throughout all activity types.
Might have to dev a custom plug in for the likes though...

@manu89ft
Copy link

Any news for notifications?

@fried-eggz
Copy link

fried-eggz commented Jun 2, 2016

I have added a hook that fires when something is liked. I use that hook to send notification on likes.

do_action('bp_like_added', $item_id, $user_id);

The hook is added in this pull request and the code that adds notifications is:

// Add notification for likes
function zombie_like_added($liked_item_id, $user_id) {

    global $wpdb;
    $statement = 'SELECT * FROM wp_bp_activity WHERE id = ' . $liked_item_id;
    $results = $wpdb->get_results( $statement, OBJECT );

    // Determin like level
    if ($results[0]->item_id == "0" || $results[0]->item_id == "1") {
        $root_level = true;
        $root_item = $results[0]->id;
    }else{
        $root_level = false;
        $root_item = $results[0]->item_id;
    }

    $liker_id   = $user_id;
    $like_owner = $results[0]->user_id;

    $args = array(
        'user_id'           => $like_owner,             // Recieves notification
        'item_id'           => $root_item,              // The item that was liked
        'secondary_item_id' => $liker_id,               // The liker
        'component_name'    => 'zombie_likes',
        'date_notified'     => bp_core_current_time(),
        'is_new'            => 1,
        );

    // Get root activity
    $activity = bp_activity_get_specific(array( 'activity_ids' => $root_item));
    $activity = $activity['activities'][0];
    $activity->user_id;

    // Root or sub level like
    switch ($root_level) {
        case true:
        $args['component_action']  = 'new_zombie_like_' . $liked_item_id . "_" . $liker_id;
        break;

        case false:
        $args['component_action']  = 'new_zombie_sub_like_' . $liked_item_id . "_" . $liker_id;
        break;
    }

    // Do not add notification when liking own item 
    if ($activity->user_id != $liker_id && $like_owner != $liker_id) {
        bp_notifications_add_notification( $args );
    }
}
add_action('bp_like_added', 'zombie_like_added', 10, 2);

@manu89ft
Copy link

manu89ft commented Jun 3, 2016

Thank you very very very much @fried-eggz ! It works!

@fried-eggz
Copy link

No problem @manu89ft. Glad to share.

@darrenmeehan you should really look at getting this fixed. I have submitted a pull request (se above) to add a hook and the code i posted here can be used to make notifications work.

@rvnamb
Copy link

rvnamb commented Aug 24, 2016

I forked the plugin and copied the above code in my functions.php file ,still i dint get a notification
can u please help me ?
the forked plugin came with the hook so i added the above zombie function to my functions.php file...its still not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants