Osclass forums
Development => Development => Topic started by: Xefiron on March 27, 2019, 01:47:04 am
-
I create a fairly simple function to do the test
function say_hello() {
echo 'Hello';
}
osc_add_hook('pre_item_post', 'say_hello');
But, when I insert the following code into a form
<?php osc_run_hook('pre_item_post'); ?>
The form filled me with codes and error messages, they entered the "Hello" I expected. How am I supposed to call only the Hook that I'm interested in? I'm particularly worried because I want to use the "posted_item" Hook that will run when I post an ad and I do not want all the hooks that are of the type "posted_item" to load.
-
May i ask why you need an hook?
If you have the function in function.php or in a plugin you can call directly the function
<?php say_hello(); ?>
If you really need an hook you can see this post https://forums.osclass.org/plugins/create-a-new-hook/msg150455/#msg150455
-
Could I do that? I guess I'll try. Thanks for your reply.
Edit: I can say that I have actually been able to call the functions in the way you mention. However, I still need to be able to capture a data at the moment a post is made.
May i ask why you need an hook?
Because I want to be able to retrieve the $ itemId of an ad at the moment it is public, since one of my main functions performs a record in a table at the moment the post of an advertisement is made.
-
Hello,
You may want to check the code of some of the free attribute plugins. They capture data from fields on an item and save them to a table on publish.
Regards.
-
You may want to check the code of some of the free attribute plugins. They capture data from fields on an item and save them to a table on publish.
I will do it, thank you very much for the recommendation.