Hello Brajesh,
I recently noticed that the code takes effect when editing a post which is not a good idea to display the message (There is one Post with the same title!) since the post is only being edited so there should not be any checks made while editing already published content.
Thanks
Hello Tosin,
Sorry for the inconvenience. Please replace with the following code:
add_filter( 'bblpro_validation_errors', function ( $errors, $data ) { if ( ! class_exists( 'Unique_Title_Checker' ) ) { return $errors; } $title_checker = Unique_Title_Checker::get_instance(); if ( empty( $data['bbl_post_title'] ) ) { return $errors; } $post_title = sanitize_text_field( wp_unslash( $data['bbl_post_title'] ) ); if ( ! empty( $data['bbl_post_id'] ) ) { $post = get_post( absint( $data['bbl_post_id'] ) ); if ( $post && $post_title == $post->post_title ) { return $errors; } } $args = array( 'post_title' => $post_title, 'post_type' => sanitize_text_field( wp_unslash( $data['bbl_post_type'] ) ), ); $validate_data = $title_checker->check_uniqueness( $args ); if ( 'error' == $validate_data['status'] ) { $errors->add( 'bbl_post_title', $validate_data['message'] ); } return $errors; }, 10, 3 );
Please give it a try.
Regards
Ravi
You must be logged in to reply to this topic.
This topic is: not resolved