Wordpress multidomain
Hello, just testing on a wordpress multisite over multiple domains. If i change my avatar on sub1.domain.com, my avatar of the same account on sub2.domain.com and on domain.com (the main website) will break.
Any help?
Uh @Sampozzo, thank you for your message. Good question.
The problem is that my plugin retrieve avatar from the local Media Library, so I have to think about how to fix it.
Matteo
Thank you @MatteoManna , the best for me is to have one single avatar over the whole network and not one avatar for every subdomain like it seems working other plugin i'm checking. I hope you will find a solution.
Hello @MatteoManna i found a very simple solution that works for me, don't know it can be added to the official plugin.
The default blog have ID = 1
just add:
switch_to_blog(1);
before the
$attachment_id = get_user_meta( $user_id, SUA_USER_META_KEY, true );
at line 74
sorry, after more testing, it doesn't work on upload in subdomains, but i think this is the direction
ok sorry again for my continue posting, this works for me, i hope to help:
add this:
$user_blog = get_user_meta( $user_id, 'primary_blog', true);
switch_to_blog( $user_blog);
at line 75, just after this:
$attachment_id = get_user_meta( $user_id, SUA_USER_META_KEY, true );
Switch again to current blog before returning avatar:
restore_current_blog();
return $avatar;
Hi @Sampozzo, thank you for code review, please send me a Pull Request.
I will review your code and then, if it's okay, I will release it.