$comment_content = trim($_POST['comment']);
// If the user is logged in
-get_currentuserinfo();
-if ( $user_ID ) :
- $comment_author = $wpdb->escape($user_identity);
- $comment_author_email = $wpdb->escape($user_email);
- $comment_author_url = $wpdb->escape($user_url);
+$user = wp_get_current_user();
+if ( $user->ID ) :
+ $comment_author = $wpdb->escape($user->display_name);
+ $comment_author_email = $wpdb->escape($user->user_email);
+ $comment_author_url = $wpdb->escape($user->user_url);
else :
if ( get_option('comment_registration') )
die( __('Sorry, you must be logged in to post a comment.') );
$comment_type = '';
-if ( get_settings('require_name_email') && !$user_ID ) {
+if ( get_settings('require_name_email') && !$user->ID ) {
if ( 6 > strlen($comment_author_email) || '' == $comment_author )
die( __('Error: please fill the required fields (name, email).') );
elseif ( !is_email($comment_author_email))
$comment_id = wp_new_comment( $commentdata );
-if ( !$user_ID ) :
+if ( !$user->ID ) :
$comment = get_comment($comment_id);
setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);