简体   繁体   English

调用wordpress函数的XMLRPC问题-损坏服务器吗?

[英]XMLRPC problems calling wordpress functions - damaging server?

I have been using methods outlined in http://kovshenin.com/2010/custom-xml-rpc-methods-in-wordpress/ to make custom XMLRPC functions. 我一直在使用http://kovshenin.com/2010/custom-xml-rpc-methods-in-wordpress/中概述的方法来制作自定义XMLRPC函数。 Everything was going fine up until recently, with many functions implemented successfully. 直到最近,一切都进行得很好,许多功能已成功实现。

In particular, I had one function that used get_users() which I could not get working (I kept getting null returned in my responses). 特别是,我有一个函数使用了无法正常工作的get_users()(我一直在响应中返回null)。 However, I noticed that all my other, originally working methods were behaving in the same way. 但是,我注意到我所有其他最初可用的方法都以相同的方式运行。 I had not edited or changed them in any way. 我没有进行任何编辑或更改。 Commenting out the new function still caused problems in my old functions. 注释掉新功能仍然会导致我的旧功能出现问题。

After a while, I got pretty angry, downloaded a fresh installation of wordpress, and copied my old functions and commented out new functions into the clean xmlrpc.php file. 一段时间后,我很生气,下载了全新的wordpress安装程序,然后复制了我的旧功能,并在干净的xmlrpc.php文件中注释了新功能。 I uploaded that to the server, and everything started magically working again. 我将其上传到服务器,然后一切又开始神奇地工作。

However, I had another crack at my new function, and seemed to break it in the exact same way again. 但是,我在新功能上遇到了另一个裂缝,并且似乎又以完全相同的方式打破了它。 My solution to use the fresh xmlrpc.php file does not seem to be working either. 我使用新鲜的xmlrpc.php文件的解决方案似乎也不起作用。

Here is the code I believe to be problematic (it is hard to tell, as I tried many different ways to write the same function, believing it was my code being wrong rather than all the methods causing errors, even if they were coded right). 这是我认为有问题的代码(很难说出来,因为我尝试了多种不同的方式编写相同的函数,认为这是我的代码是错误的,而不是所有导致错误的方法,即使它们被正确编码也是如此) 。 All my other functions up until this point had been based around using WP_Query() in different ways. 到目前为止,我所有其他功能都基于以不同方式使用WP_Query()的基础。

$blogusers = get_users();
foreach ($blogusers as $bloguser) {
    $user = get_userdata($bloguser->ID);
            //put various things into arrays etc  
    }

So if any advice could be given to 因此,如果可以给任何建议

1) restore my original methods to working order 2) allow me to return an array with information from each user of the blog 1)将我的原始方法恢复到工作状态2)让我返回一个包含博客每个用户信息的数组

That would be fantastic 那太好了

You have to define at least one parameter in function get_users() to be able to get the user's parameters in the foreach loop. 您必须在函数get_users()定义至少一个参数,以便能够在foreach循环中获取用户的参数。

Here is an example: 这是一个例子:

$blogusers = get_users('role=subscriber&orderby=nicename');
foreach ($blogusers as $bloguser) {
    echo $bloguser->display_name;
}

All parameters are here with examples. 所有参数均在此处带有示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM