This can be done using a simple build-in WordPress command.
An example of your situation:
<?php
if ( is_user_logged_in() ) {
echo '<a href="#" class="write-new-post">Write New Post</a>';
} else {
echo '<a href="#" class="Login">Login</a>';
}
?>