Title: Question about Programmatic Notifications
Last modified: September 30, 2022

---

# Question about Programmatic Notifications

 *  Resolved [djacksounds](https://wordpress.org/support/users/djacksounds/)
 * (@djacksounds)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/)
 * Hello,
 * I’m currently testing this plugin to know if it can fit for the needs of my client.
 * I’m trying to set a programmatic notification as indicated in the docs : [https://docs.bracketspace.com/notification/developer/notifications/programmatic-notifications](https://docs.bracketspace.com/notification/developer/notifications/programmatic-notifications)
   
   This function return true, so I assumed it’s working, but I can’t see the notification
   created on the notification list of the admin panel. Is the notification inserted
   in the db ? If not, is there a way to do it programmatically, and also for a 
   custom trigger ?
 * Thanks,
    Thomas

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Kuba Mikita](https://wordpress.org/support/users/kubitomakita/)
 * (@kubitomakita)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/#post-16064354)
 * Hi Thomas,
 * this function won’t add anything to the DB, it is designed to create and submit
   notifications on the fly, not store them.
 * There is a way to create a notification in the code and save it to the database,
   but I’m not sure if this is what you’re looking for.
 * Would you mind sharing your use case?
 *  Thread Starter [djacksounds](https://wordpress.org/support/users/djacksounds/)
 * (@djacksounds)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/#post-16064452)
 * Sure,
 * I would like that users have the ability to create custom notifications on their
   profile based on chosen words.
    Eg : The user choose ‘animal’ as custom notification.
   A notification is sent to the user every time ‘animal’ appears on a post, a news,…
   This notification can be viewed and edited by admin on the dashboard.
 *  Plugin Author [Kuba Mikita](https://wordpress.org/support/users/kubitomakita/)
 * (@kubitomakita)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/#post-16066782)
 * Oh, that’s nice thinking and a great use case! We plan to deliver the [Subscriptions extension](https://bracketspace.com/downloads/notification-subscriptions)
   in the future, but at the moment you indeed need to code it.
 * In this case, I’d recommend storing the data in one place, ie User meta or somewhere
   in the central repository, and just use the mentioned function to send the notification.
   This might save you all the CRUD hassle of maintaining the data in two places.
 * You could store it as regular notifications, but those created programmatically
   will be mixed with those added manually, and I expect there will be lots of them.
 * In case you want to create the notification and store it, you’d do it like so:
   [https://pastebin.com/Lm7yMXXf](https://pastebin.com/Lm7yMXXf)
 *  Thread Starter [djacksounds](https://wordpress.org/support/users/djacksounds/)
 * (@djacksounds)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/#post-16070794)
 * Many thanks for your answer. Indeed, this method will need to maintain data in
   two places. Having reflected on that and for the V1, I’m going to use notifications
   created on the fly.
 *  Thread Starter [djacksounds](https://wordpress.org/support/users/djacksounds/)
 * (@djacksounds)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/#post-16076066)
 * Hi Kuba,
 * I’m trying to use the automatic trigger testing as indicated here [https://docs.bracketspace.com/notification/developer/snippets/general/automatic-trigger-testing](https://docs.bracketspace.com/notification/developer/snippets/general/automatic-trigger-testing).
   I get the email when a new post is added, but some informations are missing, 
   like the id or the content of the post as you can see
    on this copy/paste of 
   the email :
 *     ```
       News ID: 0
   
       News permalink: https://***/news/notif-test-2/
   
       News title: Notif test 2
   
       News slug:
   
       News content:
   
       News content HTML:
   
       ...
       ```
   
 * Is it a plugin issue ?
 *  Plugin Author [Kuba Mikita](https://wordpress.org/support/users/kubitomakita/)
 * (@kubitomakita)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/#post-16078097)
 * Hmm, looks like the post might be a draft? The ID `0` is concerning, though.
 * May I ask which trigger produces this and what post are you testing? Is it a 
   draft or otherwise “incomplete” entity?
 *  Thread Starter [djacksounds](https://wordpress.org/support/users/djacksounds/)
 * (@djacksounds)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/#post-16078498)
 * The trigger that produced that notification was for a custom post type : post/
   news/published
 * I’ve also tried with post/page/updated, here’s the notif I’ve received :
 *     ```
       Page ID: 0
       Page permalink: https://***/test-4/
       Page title: Test 44673
       Page slug:
       Page content:
       Page content HTML:
       Page excerpt: Test 43
       Page status: publish
       ...
       ```
   
 * Those tests were done with all plugins deactivated and the twenty twenty theme.
 * I also tried the plugin/activated trigger, this is the notif I received :
 *     ```
       Plugin name:
   
       Plugin author name:
   
       Plugin version:
   
       Plugin website address:
   
       Plugin activation date and time: 7 October 2022 12 h 15 min
       ```
   
 * WordPress version : 6.02
    -  This reply was modified 3 years, 8 months ago by [djacksounds](https://wordpress.org/support/users/djacksounds/).
    -  This reply was modified 3 years, 8 months ago by [djacksounds](https://wordpress.org/support/users/djacksounds/).
    -  This reply was modified 3 years, 8 months ago by [djacksounds](https://wordpress.org/support/users/djacksounds/).
 *  Plugin Author [Kuba Mikita](https://wordpress.org/support/users/kubitomakita/)
 * (@kubitomakita)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/#post-16099473)
 * Thanks for the confirmation.
 * Does the same notification work if defined in admin via UI?
 * In the meantime, we’ll try to replicate this issue on our end.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Question about Programmatic Notifications’ is closed to new replies.

 * ![](https://ps.w.org/notification/assets/icon-256x256.gif?rev=3476901)
 * [Notification - Custom Notifications and Alerts for WordPress](https://wordpress.org/plugins/notification/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/notification/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/notification/)
 * [Active Topics](https://wordpress.org/support/plugin/notification/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/notification/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/notification/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Kuba Mikita](https://wordpress.org/support/users/kubitomakita/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/question-about-programmatic-notifications/#post-16099473)
 * Status: resolved