syntax question
-
hello,
I need to add a cron job. I am not sure what would be the syntax for it. The plugin docs says I need to add:
wget http://mydomainname.com/?parameters.
can you help me on how it needs to be processed under your add task?
much obliged in anticipation.
-
Hi wn nj,
Where did you found the
? In my plugin docs?
This snippet is propably used when you want to change your WordPress Cron to Server Cron. But I don’t know where and why did you found it š
If you want to add the Cron job just click the “Add Task” button and fill the simple form.
Thanks Kuba,
I am not sure what I enter in your form.
in the schedule hook, do I enter just the ?parameters or the entire http://mydomainname.com/?parameters without the wget?
can you point me in the right direction?
Thanks
Ok here is the procedure.
You can add schedule hook like this:
my_action_nameThen you can set when it should fire and optionally add parameters (one in each row). These can be only strings.
And that’s it in the admin panel.
To make it actually do something you must add some code into your functions.php theme file.
Like this:
add_action( 'my_action_name', 'my_action_name_function' ); function my_action_name_function() { // do whatever you want }Note that action hook is the one you’ve provided above in admin panel.
So, my plugin has this for the front job:
http://www.mydomainname.com/?pipes=cron&task=callaio
If I put this in the browser’s address bar, it runs.
I cannot seem to figure out of the above, what is hook and/or the argument.
Can you point me in the right direction?
Much obliged for your continued support.
Oh, now I get it š
It’s quite simple then.
Your action function should look like this:
add_action( 'my_action_name', 'my_action_name_function' ); function my_action_name_function() { wp_remote_get('http://www.mydomainname.com/?pipes=cron&task=callaio'); }Voila, cron will call your url š
Let me know if it’s working.
Can I do this suing your plugin?
If yes, what am I inserting for hook, and parameters?
If no, where would I add this? (this is the first time I am handling crons) !
Yes you can, just follow steps above and add provided function in your theme’s function.php file
OK, but I am missing a component or not making connection with your plugin; where am I entering how often to run the plugin?
Can this cron job not be entered from your plug in?
“When” and “how often” you are setting in the second column when adding new cron job. New schedule (like every 3 hours) you can add in the sidebar metabox.
OK, so I think I am beginning to understand.
In the functions, I need to create the function to execute the cron provided by original plugin requiring cron.
In your plugin, I will add a new task.
The task hook is my_action_name_function, select the time and it should then run like magic?
No arguments need to entered.
Correct?
Exactly (almost) š
Arguments are in the code – correct.
But action name is the Hook provided in ACM plugin. Second parameter is function name.
So:
add_action( '--here is hook name--', '--here is function name--' ); function --here is function name--() { --function body-- }Basically WP Cron calls the action, not the function itself.
Kuba, you should publish this as an introduction to crons!
Thank you so much.
You have not only supported your own product but also helped me tremendously in understanding what is going on. It may be trivial for you, but for me, this was Everest.
BTW, one more plug for your; I used your plugin after trying out another popular plugin which has not been update in a while. And that plugin is also not supported on the support page; worse the developer never replied me on his private domain email either.
Your plugin was able to clean up a few things the other was unable to do. You also have a cleaner and nicer interface and your support is the best!
I’m very happy that I could help you!
If you’ll got any question just start new topic here š
Thanks for all your good words!
I’ll be very thankful if you’d review this plugin here https://wordpress.org/support/view/plugin-reviews/advanced-cron-manager
Thanks again š
The topic ‘syntax question’ is closed to new replies.