Show username depending on login

This is for people building wordpress comment systems. This code determines the post after clicking "reply."

The goal is to get either the name entered in the "author" form, or the user identity (via php), depending on if the person is logged in.

success: function(data, textStatus){
    var avatar = "<?php echo get_avatar($id_or_email, 48,'/Avatar.png' ); ?>";
    var author =  "<?php if ( is_user_logged_in() ) : ?><?php echo $user_identity; ?><?php else :?>"jQuery('#author').val()  ;
    var authorurl = "<?php the_author_meta( 'user_url'); ?>";
    var timestamp = "<?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?>";
    var commenttext =  jQuery('#comment').val();

    jQuery('<li class="new-post">'+'<div class="comment-author vcard">'+avatar+
    '<div class="comment-meta">'+'<b>'+'<a href="authorurl">'+author+'</b>'+'</a>'+
    '<div class="comment-time-stamp">'+timestamp+'</div>'+'</div>'+'</div>'+
    '<div class="comment-text">'+'<p>'+'<pre class="new-post-pre">'+commenttext+'</pre>'+'</p>'+'</div>'+'</li>').insertBefore(respond);
        statusdiv.html('<p class="ajax-success" ></p>');

This is where the problem is:

 var author =  "<?php if ( is_user_logged_in() ) : ?><?php echo $user_identity; ?><?php else :?>"jQuery('#author').val()  ;


You have missing endif in your PHP code and a double quote in wrong place (if I well understand the question) :

var author =  <? if ( is_user_logged_in() ) : echo '"'.$user_identity.'"'; else: ?> jQuery('#author').val()  <? endif; ?>;

Need Your Help

Gmaps4Rails V2, adding circle

ruby-on-rails ruby-on-rails-4 gmaps4rails gmaps4rails2

Rails n00b here. I'm attempting to add circles to my maps and stuck on adding this functionality. My current view:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.