XML-RPC wp.getComments 按作者过滤?
XML-RPC wp.getComments filter by author?
我想使用 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;
}
我想使用 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;
}