Support

Home Forums Event Espresso Premium I cannot get the following code snippet to work

I cannot get the following code snippet to work

Posted: November 22, 2016 at 4:29 pm


Omar Paloma

November 22, 2016 at 4:29 pm

The following snippet was found in another forum question. EE was preventing a logged in user from buying extra tickets. this coode was recommended. It causes a fatal error. I am guessing because there is no ‘function’.

Can you help?

if ( is_user_logged_in() ) {
$current_user = get_userdata( get_current_user_id() );
if ( $current_user->user_email === $user->user_email ) {
continue;
} else {
$error_message = ‘<p>’ . __( ‘You have entered an email address that matches an existing user account in our system. You can only submit registrations for your own account or for a person that does not exist in the system. Please use a different email address.’, ‘event_espresso’ ) . ‘</p>’;
$stop_processing = true;
$field_input_error[] = ‘ee_reg_qstn-‘ . $registration->ID() . ‘-email’;
}


Omar Paloma

November 22, 2016 at 4:39 pm

Also I cannot get this code working from the Gist:

// display the base price of the ticket in the ticket selector (instead of the modified price)

add_filter( ‘FHEE__ticket_selector_chart_template__ticket_price’, ‘change_ee_ticket_selector_base_price_display’, 10, 2 );

function change_ee_ticket_selector_base_price_display( $ticket_price, $ticket ) {
return $ticket->get_ticket_subtotal();
}


Tony

  • Support Staff

November 23, 2016 at 4:08 am

The following snippet was found in another forum question.

Can you link to the original thread so we can see where that is from?

Also I cannot get this code working from the Gist:

Are you setting the ticket as taxable or using a price modifier on the ticket?


Omar Paloma

November 23, 2016 at 9:30 am

Hey Tony,

I was adding a processing fee. I understood that code was to ensure the ticket selector showed the base price.

Regarding snippet 1, that code came from the following link. I can now see that I missed a part that came from another post, but it still doesn’t work. I am thinking I must have lost a link in the code chain for fix.

https://eventespresso.com/topic/additional-attendee-email-already-exists/

https://gist.github.com/joshfeck/1131145859a3fab58f4d


Josh

  • Support Staff

November 23, 2016 at 10:03 am

Hi Omar,

Are you placing the code within its own plugin or within a functions.php file?


Omar Paloma

November 27, 2016 at 1:14 am

Hey Josh, I have tried the code in functions.php and in a custom function


Tony

  • Support Staff

November 28, 2016 at 5:40 am

I was adding a processing fee. I understood that code was to ensure the ticket selector showed the base price.

It depends how you are adding that ‘processing fee’.

So are you adding it as a ‘tax’ within EE by selecting ‘This ticket is taxable’ within the ticket settings or are you adding a price modifier to the ticket?

Regarding the code snippet, there seems to be a misunderstanding within the original thread you linked to that has followed through to here. The code you have pasted above is the code that’s used by the core plugin, it should not be added as a custom function.

The EED_WP_Users_SPCO__verify_user_access__perform_email_user_match_check hook does not allow you to return an error message that should be displayed. It’s a filter switch that allows you to enable/disable a feature, if the hook returns FALSE the user match check is skipped, if it returns anything that evaluates to TRUE then EE performs the check.

So do you not want EE to check for other users accounts that are using the email address entered into the registration form, at all?


Omar Paloma

December 10, 2016 at 3:42 pm

The processing fee is a price modifier. My desire is to show the base price of the tickets, on the ticket page, instead of the price + Modifier, regardless of whether the member/user is signed in.

I hope that answers your question, Tony.


Tony

  • Support Staff

December 12, 2016 at 8:39 am

The code you are using does not remove price modifiers from the output, it’s a subtotal before taxes which price modifiers are included in.

You need to use something like:


function change_ee_ticket_selector_base_price_display( $ticket_price, $ticket ) {
    
    $base_price = $ticket->base_price();
    
    return $base_price->amount();
}
add_filter( 'FHEE__ticket_selector_chart_template__ticket_price', 'change_ee_ticket_selector_base_price_display', 10, 2 );


Omar Paloma

December 17, 2016 at 9:27 am

Thanks Tony! That did the job.

The support post ‘I cannot get the following code snippet to work’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso