I am new to working with Wordpress and I'm using a JQuery
plugin called textcomplete with Algolia search to allow users to @ mention other users in the comment section of my site as shown in the code below.
$input.textcomplete([
{
match: /\B@(\w*)$/,
search: function(term, callback) {
lastQuery = term;
myIndex.search(term, { hitsPerPage: 5 }, function(err, content) {
if (err) {
throw err;
}
if (content.query === lastQuery) {
callback(content.hits);
}
});
},
template: function (hit) {
console.log(hit);
return hit._highlightResult.display_name.value;
},
replace: function (hit) {
return ' @' + hit.display_name + ' ';
},
index: 1
}
]);
I want to send my hit.display_name variable to the server to use as part of a MySQL
query. Normally I would do this by making it a hidden form field and posting it to the php file where it is required (in this case wp-comments-post.php) but with the way comment forms are handled with Wordpress (using a comment_form function and passing it an associative array of objects) I am not sure how to do this... So my question is how do I access this hit.display_name variable in my wp-comments-post.php file?
Aucun commentaire:
Enregistrer un commentaire