我想使用Wordpress的XML-RPC来检索与特定作者电子邮件相关的所有评论,但是wp.getComments XML-RPC API中似乎没有这种过滤器?我想检查一个好的方法,然后再为此写一个插件:)
好吧,最后我确实为此编写了一个插件。它要求直接使用Wordpress的数据库功能。这是其他需要执行此操作的人的摘录代码。享受 :)
function catsynth_getCommentsByEmail( $args ) {
global $wp_xmlrpc_server;
global $wpdb;
$wp_xmlrpc_server->escape( $args );
$blog_id = $args[0];
$username = $args[1];
$password = $args[2];
$params = $args[3];
if ( ! $user = $wp_xmlrpc_server->login( $username, $password ) )
return $wp_xmlrpc_server->error;
$email = $params["email"];
$query = "SELECT * FROM `wp_comments` WHERE `comment_author_email` = '".$email."' AND `comment_approved`=1 ORDER BY comment_date DESC LIMIT 0,30";
$comments = $wpdb->get_results($query);
foreach( $comments as $comment ) {
$comment->post_id = $comment->comment_post_ID;
$comment->post_title = get_the_title($comment->comment_post_ID);
}
return $comments;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句