そのため、json フィードを解析し、フィードからプログラムでページを生成するプラグインを作成しています。ページの作成者になるユーザーをプログラムで作成したいと考えています。問題は、username_exists()
この関数を内部的に呼び出すときにget_user_by()
、最終的に未定義の呼び出しが発生することです。私の推測では、フックする必要があるアクション、または最初に実行する必要がある他のイベントがあると思いますが、途方に暮れています。コードは次のとおりで、apache が返すエラーは次のとおりです。
/**
* A simple class for the cron user, ie the 'author' that will
* generate pages from the feed
*/
class PP_CronUser {
private static $cronUserName = 'Cron User';
private static $cronEmail = 'asdf';
private static $cronPW = 'asdf';
private static $ID = null;
public static function getUserID() {
if(!is_null(self::$ID)) return self::$ID;
if(!($id = username_exists(self::$cronUserName))) { //Here's the offending line
self::$ID = $id;
return $id;
}
self::$ID = wp_create_user(self::$cronUserName, self::$cronPW, self::$cronEmail);
return self::$ID;
}
}
エラー:
/home/who_cares/wordpress/wp-includes/user.php
致命的なエラー: 1198 行目の未定義関数 get_user_by() の呼び出し
そう定義されていますが、これは定義されていない内部的にusername_exists
呼び出します。get_user_by
何か案は?