Skip to Content Skip to Menu

how to add my own event to cb?

  • saman2
  • saman2
  • OFFLINE
  • Posts: 404
  • Thanks: 7
  • Karma: -1
6 years 2 weeks ago #307873 by saman2
how to add my own event to cb? was created by saman2
hi
i want add my own event to cb.is it possible? (without problem such as when update cb my code need to change)
i want add to this :
CB\Database\Table\UserTable->saveSafely
my own event trigger such as this:
$_PLUGINS->trigger( 'FireMyOwnEvent', array( &$this, &$this, true ) );

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8277
  • Karma: 1443
6 years 2 weeks ago #307874 by krileon
Replied by krileon on topic how to add my own event to cb?
Do not alter the core code. You will lose your changes every time you update CB. That function already has triggers for before and after the save covering both backend and frontend cases. Why are you wanting to add a new one to it?


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • saman2
  • saman2
  • OFFLINE
  • Posts: 404
  • Thanks: 7
  • Karma: -1
6 years 1 week ago #307901 by saman2
Replied by saman2 on topic how to add my own event to cb?
my problem resolved in another way...but generally i want to know if i need to add some my own event trigger what need to do?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8277
  • Karma: 1443
6 years 1 week ago #307927 by krileon
Replied by krileon on topic how to add my own event to cb?
If you need to fire a CB trigger externally you'll need to first load CBs API. See the below on how to do this.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18357-including-cb-api-for-usage-outside-of-cb

Next you just need to be sure the global $_PLUGINS is added to your function and call the trigger function after loading CBs plugins in. Example as follows.

Code:
global $_PLUGINS; $_PLUGINS->loadPluginGroup( 'user' ); $_PLUGINS->trigger( 'TRIGGER_HERE', array( VARIABLES_HERE ) );

CB Auto Actions can work with Joomla events now though so you could optionally just use a Joomla event.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum