I was wondering if name in the leave comment template can be separated to allow for first name and last name as opposed to just 开发者_开发技巧name?
Did I explain myself right? if so can someone point me to an example.
I would like to do this without having to install a module.
Thanks guys,
Matt
On the front end, you could break the name form field into two fields, then join them back together with a function hooked onto a filter, just before the comment is saved.
But at the end of the day, the name parts will still be stored as one single string in the database.
An example would be to place this in your theme's functions.php file;
function my_comment_author_join()
{
$_POST['author'] = $_POST['author_first'] . ' ' . $_POST['author_last'];
}
add_action('pre_comment_on_post', 'my_comment_author_join');
Then edit your theme's comments.php file, and replace the author field with two text fields, with the names author_first
and author_last
respectively.
精彩评论