• Resolved tcmfood

    (@tcmfood)


    Hi,

    First, thanks for the great plugin!

    May I know do you have any hooks where I can use to detect the current user’s membership level?

    I want to display a special message for the customers (depending on their membership levels) on certain pages.

    Thanks in advance!

Viewing 1 replies (of 1 total)
  • Plugin Support akshayathangaraj

    (@akshayathangaraj)

    Hi,

    Thank you so much for your kind words about our plugin – we really appreciate it!

    Currently, we don’t have a dedicated hook to detect the user’s membership level. Since loyalty levels are dynamically upgraded based on points (which can change in different scenarios), a hook isn’t available at the moment.

    However, you can achieve your requirement using the following code blocks:

    1. Fetch the current user and their loyalty data (including the level ID):

    $current_user = wp_get_current_user();
    $conditions = [
    “user_email” => [
    “operator” => “=”,
    “value” => $current_user->user_email,
    ],
    ];
    if (class_exists(“\Wlr\App\Models\Users”)) {
    $user_model = new \Wlr\App\Models\Users();
    }
    $loyalty_user =
    is_object($user_model) && method_exists($user_model, “getQueryData”)
    ? $user_model->getQueryData($conditions, “*”, [], false, true)
    : null;

    // The loyalty level ID can be accessed via:
    $level_id = $loyalty_user->level_id;

    2. Fetch the loyalty level details (if you need more information about the user’s level):

    if (class_exists(“\Wlr\App\Helpers\Base”)) {
    $base_helper = new \Wlr\App\Helpers\Base();
    }
    if (is_object($base_helper) && method_exists($base_helper, “getLevel”)) {
    $level_data = $base_helper->getLevel($loyalty_user->level_id);
    }

    With this, you can check the user’s level and display any custom message based on their membership level.

    Please give it a try and let us know if you need further assistance in implementing this.

    Regards,

    Flycart support team.

Viewing 1 replies (of 1 total)

The topic ‘Documentation on hooks?’ is closed to new replies.