简体   繁体   English

如何使用“ bp_core_fetch_avatar”替代buddypress头像?

[英]How to override buddypress avatars using “bp_core_fetch_avatar”?

Im using a custom WP plugin (ProUser) to upload user avatars. 我使用自定义WP插件(ProUser)上传用户头像。 The avatars work perfectly everywhere on my wordpress site except for buddypress. 这些头像在我的wordpress站点上的所有位置都可以完美运行,除了buddypress。 I have been doing a lot of searching and it seems buddypress handles avatars in its own (fairly ruthless) way! 我一直在进行大量搜索,看来buddypress以自己的方式(相当残酷)来处理化身! Does anyone know how to override the buddypress user avatars (but not group avatars), so that these are the same as elsewhere in the instillation (eg as found on bbpress, dashboard, etc…). 有谁知道如何覆盖buddypress用户头像(而不是组头像),以使它们与灌输中的其他角色相同(例如,在bbpress,仪表板等上找到的……)。

As far as my reading has got me this will probably involve overriding or rewriting “bp_core_fetch_avatar” to use “get_avatar” in buddypres. 就我的阅读而言,这可能涉及重写或重写“ bp_core_fetch_avatar”以在buddypres中使用“ get_avatar”。 I have been trying to do this but im not great with php and not getting very far. 我一直在试图做到这一点,但我与php并不太好,而且进展也不远。 Any help would be really appreciated. 任何帮助将非常感激。

Thanks. 谢谢。

As far as my reading has got me this will probably involve overriding or rewriting “bp_core_fetch_avatar” to use “get_avatar” in buddypres 就我的阅读而言,这可能涉及重写或重写“ bp_core_fetch_avatar”以在buddypres中使用“ get_avatar”

You would have to replace all instances of bp_core_fetch_avatar() in your templates with get_avatar() . 你将不得不更换的所有实例bp_core_fetch_avatar()在你的模板get_avatar() To my knowledge, this would be the only (and best) way of doing it. 据我所知,这将是唯一(也是最好的)方法。

Start by unhooking bp_core_fetch_avatar from the bp_get_activity_avatar calls via 首先通过bp_core_fetch_avatarbp_get_activity_avatar调用中bp_core_fetch_avatarbp_get_activity_avatar

remove_filter( 'bp_get_activity_avatar', 'bp_core_fetch_avatar');

and then writing & adding your own filter to bp_get_activity_avatar that leverages get_avatar . 然后编写自己的过滤器bp_get_activity_avatar其添加到利用get_avatar

Not sure if this will answer your question exactly (i've no experience with pro user or group avatars) but here we go.. 不知道这是否能完全回答您的问题(我没有使用专业版用户或组化身的经验),但是我们开始吧。

In bp-custom.php add.. 在bp-custom.php中添加..

add_filter('bp_core_fetch_avatar_no_grav', '__return_true');

This tells buddypress to ignore 'gravatars' and use the avatars uploaded to wordpress. 这告诉buddypress忽略“ gravatars”,而使用上载到wordpress的化身。

Better explained here by the person who came up with this solution.. 提出此解决方案的人会在此处进行更好的解释。

https://stackoverflow.com/a/34560419/3377049 https://stackoverflow.com/a/34560419/3377049

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM