How to upload avatar programatically?
-
Hi!
Wonderful plugin. It does an amazing job.
On snag I’ve run into and I’m not sure the proper way to handle it because of the custom DB tables along with the user meta values.
I just want to upload avatars for members programatically without using any frontend, and have Avatar Privacy process/handle it the way that it should.
I have a directory of images to loop through and intended to do something like this per each image/user_id after adding the images to the library and getting IDs:
update_user_meta($user_id, $wpdb->get_blog_prefix() . ‘user_avatar’, $attach_id);
…but it’s now “avatar_privacy_user_avatar” as the meta key, it’s an array, and there’s a lot more custom DB stuff behind the scenes. So I’m confused how to do this with the plugin.I’m hoping to use a magic “avatar_privacy_upload_avatar()” function I can pass the user_id and either the file URI (not uploaded) or attach_id (uploaded), and Avatar Privacy do all the magic it has to.
If there’s no straightforward way to do this, then I want to suggest this as a feature request.
As an added bonus, having the ability to set these programatically:
“Display a Gravatar image for my e-mail address.”
&
“Allow logged-out comments with my profile picture.”a magic function like
avatar_privacy_update_user($user_id, $attach_id=NULL, $delete_old=TRUE, $display_gravatar=FALSE, $display_logged_out=FALSE)
Thanks for your time.
- The topic ‘How to upload avatar programatically?’ is closed to new replies.