WordPress API

# 判断当前用户权限/用户角色
bool current_user_can( $capability);
# eg:
# bool current_user_can(‘editor’)
# bool current_user_can(‘administrator’)

$user = wp_get_current_user();
$allowed_roles = array(‘editor’, ‘administrator’, ‘author'[, …]);
if( array_intersect($allowed_roles, $user->roles ) ){
// code here
}

# 获取当前POST信息
$post = get_post();
$post->ID;

# 获取POST META数据
get_post_meta(post_id, meta_key, isUnique);

# 可视化woocommerce hook查询
https://businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google photo

You are commenting using your Google account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s