סנכרן את אווטאר מ-Discourse ל-Wordpress באופן אוטומטי

סיכום מבוסס בינה מלאכותית

The discussion is about syncing avatars from Discourse to WordPress automatically. Shauny initially asked how to achieve this, as they want to use Discourse’s avatar system instead of WordPress’. Shauny later found a solution using Webhooks and shared the general steps:

  1. creating a Discourse webhook that posts to a PHP file when a profile is updated,
  2. saving the avatar URL as a custom meta field in WordPress, and
  3. updating the WordPress code to return the meta field as the user avatar.
    jrgong and jrgong asked Shauny to share the code snippets used, to add to the WP/SSO documentation or community tutorials, which Shauny agreed to do once they have access to their computer.

I’ve tried searching but find topics about doing this the other way round but not this way…

My WordPress website is a DiscourseConnect Provider to my Discourse forum, so people log into the forum with their WordPress account.

I used to have it so you went to the website to update your avatar, using a plugin, and it uploaded that to Discourse, but I’d like to switch this around because the Discourse avatar stuff is so much nicer. I’d like it so the website grabbed the avatar from the Discourse forum on login, or whenever it changes.

How is this possible please?

Thanks!

Never mind, I managed to do this myself using Webhooks!

Hey Shaun

could you share your solution? We want to achieve the same thing, and I am curious how you managed it. :slight_smile:
Cheers
Jr

במידה ואתה לא ליד המחשב כרגע, הנה השלבים שפעלתיבתקווה שתוכל לעשות את זה אם תקרא על הדברים השונים שהשתמשת בהם:

  1. צור וובהוק של Discourse שמפרסם לקובץ PHP בתוסף/עיצוב שלך בכל פעם שמישהו מעדכן את הפרופיל שלו
  2. בדף ה-PHP, קבל את המטען שמכיל את מזהה המשתמש. קבל את כתובת ה-Avatar ממנו, ושמור אותה כרצועת מטא מותאמת אישית נגד המשתמש ב-WordPress
  3. עדכן את הקוד ב-WordPress שמחזיר את תמונת הפרופיל של המשתמש עם פונקציה שמחזירה במקום זאת את שדה המטא הזה

זהו זה!

I was rather thinking if you could share the code snippets that you used and we could add them here to WP / SSO documentation or community tutorials? :slight_smile:

Sure, once I have access to my computer :grinning_face: