• Resolved gtosnipey

    (@gtosnipey)


    I have uncanny automator setting the metafield for a CPT using the “set Metadata” action. It does that just fine and sets the field and saves it to the CPT. But this does not trigger updating the url. If I go to the CPT item and click update it then updates the URL. How can I get this to update when it sets the post meta? Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Hi @gtosnipey,

    As WordPress triggers “update_post_meta” hook after a custom field is saved, I think that is the best way to use it to make Permalink Manager regenerate and save the new custom permalink. Could you try to use the below code snippet?

    function pm_trigger_permalink_update( $meta_id, $post_id, $meta_key = '', $meta_value = '' ) {
    	if ( $meta_key == '<span style="text-decoration: underline;">custom-field-name</span>' ) {
    		$new_uri = Permalink_Manager_URI_Functions_Post::get_default_post_uri( $post_id );
    		Permalink_Manager_URI_Functions::save_single_uri( $post_id, $new_uri, false, true );
    	}
    }
    add_action( 'updated_post_meta', 'pm_trigger_permalink_update', 999, 4 );
    Plugin Author Maciej Bis

    (@mbis)

    Since you have not replied, I am marking this thread as resolved. If you have further questions, just let me know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Updating permalink when Uncanny Automator sets meta data’ is closed to new replies.