Hi,
I have a function changing the post title and slug after saving a post. It works fine in the editor, but I would like to make it work in front-end submissions. The function is:
add_action( 'rwmb_cat-and-dog-fields_after_save_post', 'update_cats_post_title');
function update_cats_post_title( $post_id ) {
if ( 'cats' == get_post_type() ) {
$animals_name = rwmb_meta( 'animals_name', '', $post_id );
$name_sequence = rwmb_meta( 'name_sequence', '', $post_id );
$author_id = get_post_field( 'post_author', $post_id );
$nickname = get_the_author_meta( 'display_name', $author_id );
$post_slug = sanitize_title_with_dashes ($my_post,'','save');
$post_slugsan = sanitize_title($post_slug);
$my_post = array(
'ID' => $post_id,
'post_title' => $nickname . ' - Cat - ' . $animals_name . ' ' . $name_sequence ,
'post_name' => $post_slugsan,
);
wp_update_post ( $my_post ) ;}
}
I know in front-end submission I must use 'rwmb_frontend_after_save_post', but I don't know how to make it work with the above function, my attempts to integrate them failed. I will greatly appreciate your assistance.
Greetings,
Tom