提问人:Vineet SND 提问时间:11/24/2022 最后编辑:mujuonlyVineet SND 更新时间:12/8/2022 访问量:69
在会员计划激活期间显示自定义头像图像
Display custom avatar image during membership plan activated
问:
我正在使用SkyVerge的WooCommerce会员资格进行会员计划,问题是,当用户购买会员资格时,他们的头像图像应更改为我的自定义图像URL,当他们的会员资格到期时,他们的头像将恢复正常
编号:https://woocommerce.com/document/woocommerce-memberships-function-reference/
add_filter('woocommerce-memberships', 'wpb_new_gravatar', 1);
$memberships = wc_memberships_get_user_active_memberships($user_id);
if ($user === $memberships) {
function wpb_new_gravatar($avatar_defaults) {
$myavatar = 'https://buysnd.com/wp-content/uploads/2022/11/Circle_Design_Membership_Level_GOLD.webp';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}
}
答:
0赞
mujuonly
11/24/2022
#1
您可能需要查看文档了解如何使用钩子,对于这种特定情况,您可以使用钩子pre_get_avatar
add_filter('pre_get_avatar', 'custom_gravatar', 10, 3);
function custom_gravatar($avatar, $id_or_email, $args) {
$uid = get_current_user_id();
if ($uid && wc_memberships_get_user_active_memberships($uid)) {
$avatar = "<img src='https://buysnd.com/wp-content/uploads/2022/11/Circle_Design_Membership_Level_GOLD.webp'/>";
}
return $avatar;
}
评论
0赞
Vineet SND
11/24/2022
嗨,你能再帮我一次吗,如果用户是会员,我希望两者都是有条件的,那么他们的阿凡达是不同的,当他不是会员时,他们就不同了?
0赞
Vineet SND
11/24/2022
为成员自定义默认 Gravataradd_filter('pre_get_avatar', 'custom_gravatar', 1, 3); function custom_gravatar($avatar, $id_or_email, $args) { $uid = get_current_user_id(); if ($uid && wc_memberships_get_user_active_memberships($uid)) { $avatar = "<img src='https://staranddaisy.in/wp-content/uploads/2022/11/Circle_Design_Membership_Level_GOLD.webp'/>"; } return $avatar; }
0赞
Vineet SND
11/24/2022
所有用户的默认 Gravataradd_filter( 'avatar_defaults', 'wpb_new_gravatar' ); function wpb_new_gravatar ($avatar_defaults) { $myavatar = 'http://staranddaisy.in/wp-content/uploads/2022/11/smily_icon_avatar-1.png'; $avatar_defaults[$myavatar] = "Default Gravatar"; return $avatar_defaults;}
评论