Discussion:
Change the user avatar url to a user meta field url?
BenderisGreat
2014-01-15 10:03:36 UTC
Permalink
I know there are plugins for handling a local user avatar, but it seems like
a giant pain in the ass to code something myself for this. I even asked
around and was told to just use a plugin, but I cannot package someone elses
plugin with what I am making.

So, I am wondering if there is a way to replace the user avatar with a user
meta field that points to a url. I know it wont technically be an avatar in
wordpress' eyes, but this would be much simple to allow front end avatar
uploading. Just select an image, store the url in a custom field, and then
have the avatar call redirected to look at the users avatar meta field.

Is this a realistic solution?



--
View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Change-the-user-avatar-url-to-a-user-meta-field-url-tp43195.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
BenderisGreat
2014-01-15 10:15:10 UTC
Permalink
Actually I am looking at the function, and if I can just change the default
avatar to be used to another function that grabs the user meta field url,
then that should work just fine right?



--
View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Change-the-user-avatar-url-to-a-user-meta-field-url-tp43195p43196.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
Nikola Nikolov
2014-01-15 10:17:58 UTC
Permalink
You can still use a plugin for that. For instance this plugin -
http://wordpress.org/plugins/user-avatar/ . It's very simple since all it
does is add interface in the edit profile page in the admin that allows you
to upload a photo to the media library(I think) and then use that as your
avatar. It also allows you to crop the photo. What I'd advice you to do is
to simply download the plugin and go through it's source - it's basically
three .php files, one of which is timthumb(yeah, I know - that's not good
in a plugin :) ).


On Wed, Jan 15, 2014 at 12:03 PM, BenderisGreat
Post by BenderisGreat
I know there are plugins for handling a local user avatar, but it seems like
a giant pain in the ass to code something myself for this. I even asked
around and was told to just use a plugin, but I cannot package someone elses
plugin with what I am making.
So, I am wondering if there is a way to replace the user avatar with a user
meta field that points to a url. I know it wont technically be an avatar in
wordpress' eyes, but this would be much simple to allow front end avatar
uploading. Just select an image, store the url in a custom field, and then
have the avatar call redirected to look at the users avatar meta field.
Is this a realistic solution?
--
http://wordpress-hackers.1065353.n5.nabble.com/Change-the-user-avatar-url-to-a-user-meta-field-url-tp43195.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Janneke Van Dorpe
2014-01-15 11:20:36 UTC
Permalink
You could also completely overwrite get_avatar() and point it to a meta field with a URL or ID to an attachment.

http://codex.wordpress.org/Function_Reference/get_avatar
Post by Nikola Nikolov
You can still use a plugin for that. For instance this plugin -
http://wordpress.org/plugins/user-avatar/ . It's very simple since all it
does is add interface in the edit profile page in the admin that allows you
to upload a photo to the media library(I think) and then use that as your
avatar. It also allows you to crop the photo. What I'd advice you to do is
to simply download the plugin and go through it's source - it's basically
three .php files, one of which is timthumb(yeah, I know - that's not good
in a plugin :) ).
On Wed, Jan 15, 2014 at 12:03 PM, BenderisGreat
Post by BenderisGreat
I know there are plugins for handling a local user avatar, but it seems like
a giant pain in the ass to code something myself for this. I even asked
around and was told to just use a plugin, but I cannot package someone elses
plugin with what I am making.
So, I am wondering if there is a way to replace the user avatar with a user
meta field that points to a url. I know it wont technically be an avatar in
wordpress' eyes, but this would be much simple to allow front end avatar
uploading. Just select an image, store the url in a custom field, and then
have the avatar call redirected to look at the users avatar meta field.
Is this a realistic solution?
--
http://wordpress-hackers.1065353.n5.nabble.com/Change-the-user-avatar-url-to-a-user-meta-field-url-tp43195.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Nikola Nikolov
2014-01-15 11:33:22 UTC
Permalink
I personally would go with the filters. Simply because there might be a
third plugin that says - "hey this user should have a special avatar(the
user added a "badge" to their photo for instance), I'll add my filter last
and I'll return my output".

After all that's the whole purpose of filters and actions in WordPress :)


On Wed, Jan 15, 2014 at 1:20 PM, Janneke Van Dorpe <
Post by Janneke Van Dorpe
You could also completely overwrite get_avatar() and point it to a meta
field with a URL or ID to an attachment.
http://codex.wordpress.org/Function_Reference/get_avatar
Post by Nikola Nikolov
You can still use a plugin for that. For instance this plugin -
http://wordpress.org/plugins/user-avatar/ . It's very simple since all
it
Post by Nikola Nikolov
does is add interface in the edit profile page in the admin that allows
you
Post by Nikola Nikolov
to upload a photo to the media library(I think) and then use that as your
avatar. It also allows you to crop the photo. What I'd advice you to do
is
Post by Nikola Nikolov
to simply download the plugin and go through it's source - it's basically
three .php files, one of which is timthumb(yeah, I know - that's not good
in a plugin :) ).
On Wed, Jan 15, 2014 at 12:03 PM, BenderisGreat
Post by BenderisGreat
I know there are plugins for handling a local user avatar, but it seems like
a giant pain in the ass to code something myself for this. I even asked
around and was told to just use a plugin, but I cannot package someone elses
plugin with what I am making.
So, I am wondering if there is a way to replace the user avatar with a
user
Post by Nikola Nikolov
Post by BenderisGreat
meta field that points to a url. I know it wont technically be an
avatar
Post by Nikola Nikolov
Post by BenderisGreat
in
wordpress' eyes, but this would be much simple to allow front end avatar
uploading. Just select an image, store the url in a custom field, and
then
Post by Nikola Nikolov
Post by BenderisGreat
have the avatar call redirected to look at the users avatar meta field.
Is this a realistic solution?
--
http://wordpress-hackers.1065353.n5.nabble.com/Change-the-user-avatar-url-to-a-user-meta-field-url-tp43195.html
Post by Nikola Nikolov
Post by BenderisGreat
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Janneke Van Dorpe
2014-01-15 11:50:17 UTC
Permalink
Agreed, you could overwrite it both ways. Filters are preferable.
Post by Nikola Nikolov
I personally would go with the filters. Simply because there might be a
third plugin that says - "hey this user should have a special avatar(the
user added a "badge" to their photo for instance), I'll add my filter last
and I'll return my output".
After all that's the whole purpose of filters and actions in WordPress :)
On Wed, Jan 15, 2014 at 1:20 PM, Janneke Van Dorpe <
Post by Janneke Van Dorpe
You could also completely overwrite get_avatar() and point it to a meta
field with a URL or ID to an attachment.
http://codex.wordpress.org/Function_Reference/get_avatar
Post by Nikola Nikolov
You can still use a plugin for that. For instance this plugin -
http://wordpress.org/plugins/user-avatar/ . It's very simple since all
it
Post by Nikola Nikolov
does is add interface in the edit profile page in the admin that allows
you
Post by Nikola Nikolov
to upload a photo to the media library(I think) and then use that as your
avatar. It also allows you to crop the photo. What I'd advice you to do
is
Post by Nikola Nikolov
to simply download the plugin and go through it's source - it's basically
three .php files, one of which is timthumb(yeah, I know - that's not good
in a plugin :) ).
On Wed, Jan 15, 2014 at 12:03 PM, BenderisGreat
Post by BenderisGreat
I know there are plugins for handling a local user avatar, but it seems like
a giant pain in the ass to code something myself for this. I even asked
around and was told to just use a plugin, but I cannot package someone elses
plugin with what I am making.
So, I am wondering if there is a way to replace the user avatar with a
user
Post by Nikola Nikolov
Post by BenderisGreat
meta field that points to a url. I know it wont technically be an
avatar
Post by Nikola Nikolov
Post by BenderisGreat
in
wordpress' eyes, but this would be much simple to allow front end avatar
uploading. Just select an image, store the url in a custom field, and
then
Post by Nikola Nikolov
Post by BenderisGreat
have the avatar call redirected to look at the users avatar meta field.
Is this a realistic solution?
--
http://wordpress-hackers.1065353.n5.nabble.com/Change-the-user-avatar-url-to-a-user-meta-field-url-tp43195.html
Post by Nikola Nikolov
Post by BenderisGreat
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
BenderisGreat
2014-01-19 08:24:52 UTC
Permalink
Thanks Nikola - I took your advice and filtered it. I am not sure why
everyone says it's a pain now (or maybe I just spoke with the wrong people)
but that was incredibly easy. Just code an upload form, store url to file
in usermeta, and then filter the get_avatar function and have it check that
usermeta first. Thats correct, right? I dont really see how there are
entire plugins dedicated to this now either.



--
View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Change-the-user-avatar-url-to-a-user-meta-field-url-tp43195p43210.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
Otto
2014-01-19 08:51:42 UTC
Permalink
Yep, that's the easy way. And, as you will find, plugins get more
complex as time goes by. :)


-Otto


On Sun, Jan 19, 2014 at 2:24 AM, BenderisGreat
Post by BenderisGreat
Thanks Nikola - I took your advice and filtered it. I am not sure why
everyone says it's a pain now (or maybe I just spoke with the wrong people)
but that was incredibly easy. Just code an upload form, store url to file
in usermeta, and then filter the get_avatar function and have it check that
usermeta first. Thats correct, right? I dont really see how there are
entire plugins dedicated to this now either.
--
View this message in context: http://wordpress-hackers.1065353.n5.nabble.com/Change-the-user-avatar-url-to-a-user-meta-field-url-tp43195p43210.html
Sent from the Wordpress Hackers mailing list archive at Nabble.com.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Continue reading on narkive:
Loading...