[wp-hackers] On slug change, do something

Nicholas Ciske nl at thoughtrefinery.com
Tue Jul 30 14:41:49 UTC 2013

permalink_structure_changed fires when the permalink structure is changed on the Settings page -- not when a slug is updated.

You're probably looking for the edit_terms action which fires just before the term slug is updated (keep in mind that one term can be in multiple taxonomies). This gets run in wp_update_term() in wp-includes/taxonomy.php.

This triggers every time a term is updated, you'll need to write some code to determine if the slug has actually changed or not.

Nick Ciske

On Jul 29, 2013, at 9:44 PM, Haluk Karamete wrote:

> I'd like to hook into the event when a tag slug changes, I can fire an
> action - for the sake of simplicity, let's say, I want to send en email
> when a tag slug is modified.
> I tried the  following piece of code but that did not do the trick. I'm
> curious to know what is it that I need to do?
> add_action("permalink_structure_changed","do_something");
> function do_something($data){
> wp_mail( 'an_email_address_here', 'subject_here', 'some text here');
> }
> To try this, I changed the slug of a post_tag, but no email was fired.
> I also tried changing the permalink of a post, that did not fired an email
> neither.
> What's the hook to tap into when a slug is changed? I'm particularly
> interested in post_tag slugs change,
> Thanks

More information about the wp-hackers mailing list