Support » Plugin: WooCommerce » WooCommerce Memberships Directory Shortcode

  • Resolved dima011

    (@dima011)


    hello, I need to display a list of users of a specific woocommerce membership for this I use a shortcode
    [wcm_directory plans = “silver, gold” status = “active, complimentary” per_page = “24” bios = “no” avatars = “yes” avatar_size = “90”] but there is one problem there is no link to the user profile, maybe someone knows how to add a link to a member’s profile?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Mirko P.

    (@rainfallnixfig)

    Hi @dima011,

    Support for WooCommerce Memberships is provided at https://woocommerce.com/my-account/create-a-ticket/?form=ticket.

    Please login to WooCommerce.com with the account you’ve used to purchase the extension, select WooCommerce Memberships from the dropdown list so that the query ends up in the right queue. We’ll help you from there.

    Thanks!

    The shortcode in the plugin doesn’t support linking to the profile by default. You would need to add that functionality yourself. You could copy and modify this file from the plugin’s templates to your theme and make the customizations there depending on where and how you want the link to show
    woocommerce-memberships/templates/member-directory-listing.php

    Alternatively, you could also remove the wc_memberships_member_directory_before_member_card action and replace it with a custom action that adds the link, but it’s probably easier for you to just modify the template.

    Thread Starter dima011

    (@dima011)

    thanks for the hint, might this work?
    do_action( ‘wc_memberships_member_directory_before_member_author_link’, get_the_ID(), get_the_author_meta( ‘ID’ ), $shortcode );

    if ( ‘yes’ === $shortcode[‘author_link’] && get_the_author_meta( ‘description’ ) ) :

    ?>
    <p class=”member-author_link”><?php the_author_meta( ‘description’ ); ?></p>
    <?php

    endif;

    While in concept that would be a good idea, you can’t just create your own action like that unless you modified the plugin and essentially created a custom version that could no longer be updated without losing changes. I searched the code quick and it looks like there is actually a filter available to modify a shortcode_tag, so you could technically hook into the wcm_directory shortcode, but would be more complex and not entirely sure you could achieve what you want.

    You would only be able to hook into existing actions or modify the templates available. For instance, if you open member-directory-listing.php and wanted to make the avatar the link, you could change this line:
    <?php echo get_avatar( get_the_author_meta( 'ID' ), (int) $shortcode['avatar_size'] ); ?>

    To something like this:
    <?php echo "<a href='".get_author_posts_url( get_the_author_meta( 'ID' ) )."'>". get_avatar( get_the_author_meta( 'ID' ), (int) $shortcode['avatar_size'] )."</a>"; ?>

    Or you could output the link anywhere else you wanted in that template. Modifying the template is the easiest way. You copy that template file directly into your theme directory and modify it there. It DOES NOT go into the woocommerce template directory if you have one within your theme nor a woocommerce-membership directory. Just directly in your theme directory.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WooCommerce Memberships Directory Shortcode’ is closed to new replies.