rwmb_xxxxxxxx_after_save_post not working after post type slug change

Support MB Custom Post Type rwmb_xxxxxxxx_after_save_post not working after post type slug change

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #38277
    Jerome MansbendelJerome Mansbendel
    Participant

    Hello there,

    rwmb_xxxxxxxx_after_save_post hook is no longer working after I changed the slug of a custom post type.
    Is there somethign to do to fix that ?

    With best regards,

    Jerome

    #38282
    Long NguyenLong Nguyen
    Moderator

    Hi Jerome,

    Can you please share the code that creates the callback function hooks to the action rwmb_after_save_post? Do the field group and custom fields work with the new post type slug? Changing the post type slug might lead to many unexpected issues on your site.

    #38284
    Jerome MansbendelJerome Mansbendel
    Participant

    Hi Long,

    Here is the callback function hook :

    add_action( 'rwmb_logbook_after_save_post', 'update_logbook_post_title' );
    function update_logbook_post_title( $post_id ) {
    // Get the field value
    $patient_id = rwmb_meta( 'post-patient', '', $post_id );
    $service_id = rwmb_meta( 'post-service_reanimation', '', $post_id );

    // On vérifie si le slug est un uuid
    // Autrement on génère un uuid pour le slug et pour le code d'invitation
    $post_slug = get_post_field( 'post_name', get_post() );
    if (!wp_is_uuid($post_slug)) {
    $uuid = wp_generate_uuid4();
    $my_post = array(
    'ID' => $post_id,
    'post_title' => $service_id . '-' . $patient_id,
    'post_name' => $uuid
    );

    $uuidHiddenToken = wp_generate_uuid4();
    update_post_meta($post_id, 'hidden-token', $uuidHiddenToken);
    }
    wp_update_post( $my_post );
    }

    I changed custom post type slug from "journal-de-bord" to "logbook".

    With best regards,

    Jerome

    #38296
    Long NguyenLong Nguyen
    Moderator

    Hi,

    So which part/function that does not work after changing the CPT slug? update_post_meta() or wp_update_post()

    Can you please also share the code that creates the field group logbook? I see that in this action hook rwmb_logbook_after_save_post.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.