I would like to write a function to email me the URL of the website when my theme is activated.
What is the hook initiated when the theme is activated?
I would like to write a function to email me the URL of the website when my theme is activated.
What is the hook initiated when the theme is activated?
You must be logged in to post a comment.
I have that code here just name the file theme_activation_hook.php like on the website and copy this.
I have written a code which provides a reliable activation/deactivation theme hooks. Please check it out and let me know what you guys think!
http://www.krishnakantsharma.com/2011/01/activationdeactivation-hook-for-wordpress-theme/
There is no specialized hook for this. I have seen couple of approaches:
switch_theme
hook with checking for your theme – Execute âSetupâ Code on Activation only?I want to note that emailing yourself any information without user’s consent (and running anything on activation has no opportunity to request such) can be viewed as inappropriate.
WordPress now provides this hook as
after_switch_theme
. You can use it like so:You can use the
switch_theme
hook to run code on theme deactivation as well.Source: http://codex.wordpress.org/Plugin_API/Action_Reference/after_switch_theme
Place this code at the top in your
functions.php
replace
mail@yourdomain.com
with your own email address.Hope it helps.