如何添加特定用户wordpress的价目表



我想为特定用户创建一个价目表,例如:

用户1查看价目表1用户2查看价目表2

如果你使用woocomerce,一种方法与下面的woocommerce_get_price过滤器太挂钩了(在你的主题functions.php中使用这个过滤器(:

add_filter('woocommerce_get_price', 'mlnc_price_user_based', 10, 2);
function mlnc_price_user_based($price, $product) {
if (!is_user_logged_in()) return $price;
//check if the user has a role of dealer using a helper function, see bellow
$current_user = wp_get_current_user();
if ($current_user->roles[0] == 'administrator'){
//give user 10% of
$price = $price * 0.5;
}
return $price;
}

在这个例子中,我按用户角色过滤用户

无论如何,你必须提供更多的信息,比如@Damocles提到的

最新更新