Auto generate custom post title

Something like this should do the trick using JS to set the title on initial load of a new post. You will not need to differentiate between publish/draft etc. and you can let WordPress sanitize.

function set_post_title( $post ) {
    global $current_user;

    if( get_post_type() != 'interviews' || $post->post_status != 'auto-draft' )
        return;

    $uniqueid_length = 8; 
    $uniqueid = crypt(uniqid(rand(),1)); 
    $uniqueid = strip_tags(stripslashes($uniqueid)); 
    $uniqueid = str_replace(".","",$uniqueid); 
    $uniqueid = strrev(str_replace("https://wordpress.stackexchange.com/","",$uniqueid)); 
    $uniqueid = substr($uniqueid,0,$uniqueid_length);
    $uniqueid = strtoupper($uniqueid);

    $title="INTERVIEW: " . $current_user->first_name . ' ' . $current_user->last_name . ' - ' . $uniqueid . ' - ' . date( 'Ymd' );

    ?>
    <script type="text/javascript">
    jQuery(document).ready(function($) {
        $("#title").val("<?php echo $title; ?>");
        $("#title").prop("readonly", true); // Don't allow author/editor to adjust the title
    });
    </script>
    <?php
} // set_post_title
add_action( 'edit_form_after_title', 'set_post_title' ); // Set the post title for Custom posts

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)