I have a shared account, lets call it "marketing". Now I have three people using this account named Anna, Ben and Max.
When someone logs into this account and wants to type a comment with their name, it always shows the name "marketing" as author. How can I change this so that I put a name in my input field and I get the value from this as my comment author. In my comments.php I do not check if the user is logged on and call it here:
<input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="2"/>
I tried to make following in my functions.php:
function change_author( $commentdata ) {
if ( $commentdata['user_ID'] == 2 ) { // User ID for Marketing
$commentdata['user_ID'] = 0;
$commentdata['comment_author'] = '';
}
return $commentdata;
}
add_filter( 'preprocess_comment' , 'change_author' );
In this case my comment_author will always be Anonymous and also if I set it to NULL
.
When i give the variable a value $commentdata['comment_author'] = 'test';
I get "test" as my comment_author but as I said, I would like to have the value I set in my input field. It works for not logged in users very well so I thought there might be a trick for logged in users as well.
In phpMyAdmin I checked for the entries in the database and it is giving me the right values for ID etc. But it also empties the comment_author field which results in an anonymous author.
I really hope that somebody can give me the right hint to accomplish this task.