Created
February 22, 2024 16:00
-
-
Save dantetesta/c26f1d6502c3baf3989aa13f08cd2722 to your computer and use it in GitHub Desktop.
Slug Update JetFormBuilder Call a Hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Crie um campo de texto chamado slug | |
Adicione um call a hook notification -- jet-form-builder/custom-filter/save-slug | |
*/ | |
add_action( 'jet-form-builder/form-handler/after-insert-post', function( $data ) { | |
// Certifique-se de que o campo 'slug' está presente nos dados enviados | |
if ( ! empty( $data['slug'] ) ) { | |
$slug = sanitize_title( $data['slug'] ); | |
// Atualiza o post com o slug fornecido | |
wp_update_post( array( | |
'ID' => $post_id, | |
'post_name' => $slug, // WP usa 'post_name' para armazenar o slug | |
) ); | |
} | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment