Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Notification is created but can’t list it for the user

  • @doublef

    Participant

    Hello,

    I have a really weird issue with Buddypresss, I can create notifications but they’re not received by the user… Every components are enabled btw.

    If I do :

    
    bp_notifications_add_notification( array(
    'user_id'           => get_current_user_id(),
    'item_id'           => 630,
    'secondary_item_id' => 1080,
    'component_name'    => 'my_app',
    'component_action'  => 'my_app_action',
    'date_notified'     => bp_core_current_time(),
    'is_new'            => 1,
    ) );
    

    Where 630 and 1080 are valid WordPress posts and my_app component has been registered sooner.

    If I check my database, that’ll create a new entry as expected and I do :

    bp_notifications_get_notification(306)

    (306 is my new notification’s id) It does return the notification object.

    However, if I do :

    bp_notifications_get_notifications_for_user(3)

    (3 is the current_user_id())

    Then it returns false and bp_notifications_get_all_notifications_for_user() an empty array.

    What am I missing ?

    Thanks for the help, please let me know if you need more details.

    Cheers,

    François

Viewing 11 replies - 1 through 11 (of 11 total)
  • @shanebp

    Moderator

    'secondary_item_id' should be the user id of the person creating the notification.
    That might be the problem.

    @doublef

    Participant

    Hello @shanebp,

    I’ve changed the secondary_item_id with : get_current_user_id()

    And it’s the same issue, notification is created but doesn’t seem to be assigned to any profile :/

    Thanks for the help.

    @danbp

    Participant

    Hi,

    have you read this ?

    bp_notifications_add_notification

    @doublef

    Participant

    Hello,

    Yes, several times and I’ve also looked the function within the Buddypress’s plugin and it seems to work out as a notification ID is returned.

    That’s why I’m out of clue on that one…

    @shanebp

    Moderator

    When you register your component, in function setup_globals, what value ( function name ) do you give to 'notification_callback' ? And does that function exist?

    @doublef

    Participant

    That might be the issue, I’m only using some : bp_activity_set_action() calls within a :
    add_action( 'bp_register_activity_actions', 'myfunction_register_activity_actions' );

    Do I need to do anything else ? If I’ve missed a documentation page, please let me know.

    Also, within the bp_activity_set_action(), I’ve let the default callback function as I didn’t found any details within the doc and in the functions’ code. I’ve let : bp_activity_format_activity_action_activity_update

    Do you think that could be the issue ?

    @shanebp

    Moderator

    Set up a custom notification callback. Look at existing BP components to see how it is handled.

    @doublef

    Participant

    Thanks for the help @shanebp, I’ll give it a go on tomorrow morning.

    @doublef

    Participant

    Ok I had a look on the other extensions, I understand what you mean about the callback functions.

    Is there any other way around ? Because I don’t need a “new extension”, we just need something pretty simple :

    Post created > New Activity > New notification on Buddypress

    Do I need to create a new Bp component for that ?

    The activity item is created, just no notification triggered…

    Thanks for your precious help

    @shanebp

    Moderator

    @doublef

    Participant

    Thank you SO much, that did the trick just fine 🙂

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Resolved] Notification is created but can’t list it for the user’ is closed to new replies.
Skip to toolbar