Wp custom post custom capability not working together

It appears that wordpress does not check the edit_post capability while saving. Instead it checks for the author. So I used a hack to override the author id. So, wordpress thinks you are changing the author and works by first changing the author to your own id. You can add this code below in your functions.php to fix this issue.

function your_function() {
    echo '
    <script>
    // Hack to let authorised people of the department manupulate the registration.
    jQuery(document).ready(function($){
        $(\'<input id="post_author_override" type="hidden" name="post_author_override" />\')
            .val( $("#user-id").val() )
            .prependTo("form");
    });
    </script>';
}
add_action( 'wp_footer', 'your_function' );

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