What group is the user

This topic contains 5 replies, has 2 voices, and was last updated by WCFM Forum WCFM Forum 1 month, 2 weeks ago.

  • Author
    Posts
  • #87372
    Avatar
    PATselov
    Participant

    I need a filter to find out which group a registered user has? To display this information anywhere in my template or use it …

  • #87525
    WCFM Forum
    WCFM Forum
    Keymaster

    Hi,

    Well, groups are related to membership.

    You may filter vendors by membership at vendors listing dashboard – https://ibb.co/kq5k714

    You may also create store list page by membership – https://docs.wclovers.com/store-list/

    Thank You

  • #87797
    Avatar
    PATselov
    Participant

    No, you do not understand me.
    How can a user group be defined programmatically?
    I need, depending on the user group, to work with my data when writing the page template.
    For example:

    <?php
    if ($my_user_group == ... ) {
    // My code
    } else {
    // My code
    }
    ?>

    Therefore, I need to get the group value for a user who has logged into his woocommerce account.

  • #88376
    WCFM Forum
    WCFM Forum
    Keymaster

    HI,

    You may fetch vendor’s group by this –

    $wcfm_user_groups = (array) get_user_meta( $user_id, '_wcfm_vendor_group', true );

    Well, it’s return an array as one vendor may associate with multiple group.

    Thank You

  • #88409
    Avatar
    PATselov
    Participant

    This code does not work.
    The result is an empty array.

  • #88585
    WCFM Forum
    WCFM Forum
    Keymaster

    What you have passed “$user_id”?

    You have to pass a valid a vendor user id to get his/her group.

    Thank You

You must be logged in to reply to this topic.