我为插件编写的代码出现以下错误:
错误:致命错误:对中的非对象调用成员函数get\\u Error\\u code()/wp登录。php在线335
我尝试在wp登录中进行var\\u转储($错误)。php并返回NULL。
我的插件:(将注册用户添加到外部数据库)
function add_user_to_SF($errors, $sanitized_user_login, $user_email ) {
global $SF_USERNAME;
global $SF_PASSWORD;
global $errors;
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(CD_PLUGIN_PATH . \'Toolkit/soapclient/enterprise.wsdl.xml\');
$mySFlogin = $mySforceConnection->login($SF_USERNAME, $SF_PASSWORD);
$sObject = new stdclass();
$sObject->FirstName = $_POST[\'user_login\'];
$sObject->LastName = $_POST[\'user_login\'];
$sObject->Email = $_POST[\'user_email\'];
$createResponse = $mySforceConnection->create(array($sObject), \'Contact\');
$ids = array();
foreach ($createResponse as $createResult) {
array_push($ids, $createResult->id);
}
} catch (Exception $e) {
$errors->add( \'demo_error\', __(\'<strong>ERROR</strong>: There is a Salesforce problem.\',\'mydomain\') );
return $errors;
}
}
add_filter( \'registration_errors\', \'add_user_to_SF\', 10, 3 );
此外,当我使用此函数测试流程时,一切都很顺利。
function myplugin_registration_errors ($errors, $sanitized_user_login, $user_email) {
if ( empty( $_POST[\'first_name\'] ) )
$errors->add( \'first_name_error\', __(\'<strong>ERROR</strong>: You must include a first name.\',\'mydomain\') );
return $errors;
}
add_filter( \'registration_errors\', \'myplugin_registration_errors\', 10, 3 );