Advertisement:

Author Topic: [Solved]Call A function after ad is posted  (Read 840 times)

Abhi

  • Jr. Member
  • **
  • Posts: 78
  • Love what you do :)
[Solved]Call A function after ad is posted
« on: June 04, 2016, 09:37:54 am »
hi I am developing plugin and i want to call a function just after ad is posted or the ad is being updated like the emails are getting sent but i want this functionality to be in a plugin not to modify in osclass core. Looking forward for someone to help me in this regard
« Last Edit: June 04, 2016, 10:56:37 pm by Abhi143u11 »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Call A function after ad is posted
« Reply #1 on: June 04, 2016, 10:04:41 am »
Hi,

There are two hooks "posted_item'" and "edited_item":

Code: [Select]
<?php
function cust_after_add_published($item) {
    
// $item is an array with all the new ad data
    // Code here
}

function 
cust_after_add_edited($item) {
    
// $item is an array with all the edited ad data. Mind that this is slightly different to the one sent to the other function
    // Code here
}

osc_add_hook('posted_item''cust_after_add_published');
osc_add_hook('edited_item''cust_after_add_edited');
?>

Hope it will be useful for you.

Regards
« Last Edit: June 04, 2016, 10:52:34 am by teseo »

Abhi

  • Jr. Member
  • **
  • Posts: 78
  • Love what you do :)
Re: Call A function after ad is posted
« Reply #2 on: June 04, 2016, 10:46:30 pm »
Hi teseo thanks your functions idea worked like charm for me  8)

I just want one more help if possible I want to store a user id and password for a particular service from the plugin with setting please guide me a bit in this

I will be releasing my plugin soon for testing


teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: [Solved]Call A function after ad is posted
« Reply #3 on: June 05, 2016, 02:11:08 am »
I guess youl'll need to create a new table in the database to store that data... ??? Take a look at how other plugins manage that.

Regards