Only specific user role can order tickets?

Home Forums Ticket Products Event Tickets Plus Only specific user role can order tickets?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #950061
    wervelweb
    Participant

    Hello,

    Is there a way that only a specific user role can order tickets?
    So only one specific user role can add tickets to cart!
    And regular customers can see the tickets but cannot add it to cart.

    Thanx

    Nasco

    #950088
    Brian
    Keymaster

    Hi,

    Thanks for using WooCommerce Tickets.

    Unfortunately, we do not have a feature to limit ticket purchases to specific role.

    You could use WordPress’s current_user_can check to wrap the Add to Cart Button on the Event Ticketing Form to get what you are looking for.

    To edit the ticket form follow our Themer’s Guide:

    https://theeventscalendar.com/knowledgebase/themers-guide/

    To move and edit this file in your theme:

    wootickets\views\wootickets\tickets.php

    There you can see the Add to Cart Button and wrap that in the current_user_can function to only show to certain WordPress roles.

    Please note that is about as much as we can do for customizations, that will get you started, but you are going to have to take it from here.

    Let me know if you have any follow up questions.

    Thanks

    #950558
    wervelweb
    Participant

    Hi Brian

    I already used current_user_can for showing different buttons for each role.
    That works perfect but when non members entered wrong login credentials.. (we have a login below the button!!)
    the form action still processes “wootickets_process’, 1” and the ticket got added to cart.

    But you made me thinking!…
    I used current_user_can script in form action and that fixed the problem.

    Thanx

    <form action=”<?php
    if( current_user_can( ‘administrator’ ) ){ echo esc_url( add_query_arg( ‘wootickets_process’, 1, $woocommerce->cart->get_cart_url() ) );}
    //——————————————–//
    elseif( current_user_can( ‘customer’ ) ){ echo ”;}
    //——————————————–//
    elseif( current_user_can( ‘MEMBER’ ) ){ echo esc_url( add_query_arg( ‘wootickets_process’, 1, $woocommerce->cart->get_cart_url() ) );}
    //——————————————–//
    else{ echo ”;}
    //——————————————–//
    ?>”
    class=”cart” method=”post” enctype=’multipart/form-data’>

    #950563
    Brian
    Keymaster

    Great! I am glad to see you were able to figure it out.

    I am going to go ahead and close this ticket. If you have a similar issue or another in the future, please do not hesitate to create a new ticket.

    Thanks!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Only specific user role can order tickets?’ is closed to new replies.