Welcartで会員のランクを判別する
Welcart1.0ではメンバー・会員のランクを登録できるが、それを取り出す関数が特に用意されているわけではないらしい。
そこでこんなスクリプトを作ってみた、というか、
functions/template_func.php、usces_the_member_point( )を定義する部分と、
inccludes/member_edit_form.php、10行目〜20行目のパクリです。
function usces_the_member_status() {
global $usces,$wpdb;
if( !$usces->is_member_logged_in() ) return $res = -1;
$member = $usces->get_member();
$ID = $member[ID];
$tableName = $wpdb->prefix . "usces_member";
$query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $ID);
$data = $wpdb->get_row( $query, ARRAY_A );
$res = $data[mem_status];
return $res;
}
これをテーマディレクトリの「functions.php」にでも追記しておく。
データの取り出しは、
<?php echo usces_the_member_status(); ?>
などとすると、会員のランクを表示できる。
usces_the_member_status()の値は以下のようになる。
-1 >> ログインしていないユーザー
0 >> 通常会員
1 >> 優良会員
2 >> VIP会員
99 >> 不良会員
↓優良会員やVIP会員専用のコンテンツ作成に使えるかも。