1

客户通常可以在其仪表板中取消会员资格。我如何限制特定会员资格(隐藏取消按钮)?

我发现这个代码用于一般隐藏取消按钮,工作到目前为止:

function sv_edit_my_memberships_actions( $actions )
{   
    unset( $actions['cancel'] );
    return $actions}
add_filter( 'wc_memberships_my_account_my_memberships_actions', 'sv_edit_my_memberships_actions' );
}

也许有这个功能?

wc_memberships_is_user_active_member( $current_user_id, 'membership-name' )
4

2 回答 2

0

你快到了。您已经犯了@mujeeb 指定的一些语法错误。试试下面的代码

function sv_edit_my_memberships_actions( $actions )
{   
    $user_id = get_current_user_id();
    if(wc_memberships_is_user_active_member( $user_id, 'silver' )){// Instead of silver you can give your membership type
         unset( $actions['cancel'] );
    }
    return $actions;
}
add_filter( 'wc_memberships_my_account_my_memberships_actions', 'sv_edit_my_memberships_actions' );
于 2017-05-24T10:32:55.790 回答
-1
function sv_edit_my_memberships_actions( $actions ) {
    unset( $actions['cancel'] );
    return $actions;
}
add_filter( 'wc_memberships_members_area_my_memberships_actions', 'sv_edit_my_memberships_actions' );
于 2017-05-24T09:16:01.763 回答