you code may like
$posts_array = get_posts( array( 'post_type' => 'download', 'post_status' => 'publish' ) );
//$posts_array = apply_filters( 'downloads_shortcode', $posts_array );
foreach($posts_array as $post) {
setup_postdata($post);
if ( is_user_logged_in() ){
$title = "<a href="https://wordpress.stackexchange.com/questions/100335/. get_permalink( $post->ID ) .">" . $post->post_title . "</a>";
echo $title;
}
else{
// do something
}
}
Note:If you want to show post link depand upon user login and their role or capabilities use current_user_can