Home › Forums › Ticket Products › Event Tickets Plus › Only specific user role can order tickets?
- This topic has 3 replies, 2 voices, and was last updated 9 years, 1 month ago by Brian.
-
AuthorPosts
-
March 22, 2015 at 9:29 pm #950061wervelwebParticipant
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
March 23, 2015 at 4:52 am #950088BrianKeymasterHi,
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
March 24, 2015 at 12:15 pm #950558wervelwebParticipantHi 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’>March 24, 2015 at 12:24 pm #950563BrianKeymasterGreat! 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!
-
AuthorPosts
- The topic ‘Only specific user role can order tickets?’ is closed to new replies.