Custom Capabilities for CPT and Problem with current_user_can()

Solved!

Meta Capabilities edit_product, delete_product, ‘read_product` etc should be handled separately. Below code is from Justin Tadlocks Site

add_filter( 'map_meta_cap', 'fac_map_meta_cap', 10, 4 );

function fac_map_meta_cap( $caps, $cap, $user_id, $args ) {

    /* If editing, deleting, or reading a product, get the post and post type object. */
    if ( 'edit_product' == $cap || 'delete_product' == $cap || 'read_product' == $cap ) {
        $post = get_post( $args[0] );
        $post_type = get_post_type_object( $post->post_type );

        /* Set an empty array for the caps. */
        $caps = array();
    }

    /* If editing a product, assign the required capability. */
    if ( 'edit_product' == $cap ) {
        if ( $user_id == $post->post_author )
            $caps[] = $post_type->cap->edit_posts;
        else
            $caps[] = $post_type->cap->edit_others_posts;
    }

    /* If deleting a product, assign the required capability. */
    elseif ( 'delete_product' == $cap ) {
        if ( $user_id == $post->post_author )
            $caps[] = $post_type->cap->delete_posts;
        else
            $caps[] = $post_type->cap->delete_others_posts;
    }

    /* If reading a private product, assign the required capability. */
    elseif ( 'read_product' == $cap ) {

        if ( 'private' != $post->post_status )
            $caps[] = 'read';
        elseif ( $user_id == $post->post_author )
            $caps[] = 'read';
        else
            $caps[] = $post_type->cap->read_private_posts;
    }

    /* Return the capabilities required by the user. */
    return $caps;
}

error code: 523