For all you programmers out there that, like me, want to be able to automate jobs to run on-demand from the CL! I do like the data managers, but they expect $vbulletin to have the user state set. The 'hard' bit here was to figure out: how do I force $vbulletin to represent a particular user? Fortunately it turns out to be easier than I thought.
Note: you must do the normal include of global.php (at least) to get $vbulletin. E.g.:
PHP Code:
$oldPath = getcwd();
chdir('<your_vb_path_here>');
require_once('./global.php');
// Other includes from VB you might need
chdir($oldPath);
Then you can impersonate a user:
PHP Code:
$userid = '1';
// Become our user
$vbulletin->userinfo = fetch_userinfo($userid);
With just that, you can now pass $vbulletin to any of the data managers as if it was the user itself doing it.
For instance, in my case I've added some custom userfields to represent API credentials for an MMO which they must fill in correctly at registration. I then have a cronjob to fetch all users that are registered, get their API details, fetch their MMO Avatar image and set it as their forum avatar. Easy!
Hope it helps some people, I couldn't find documentation on user impersonation.