Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //* Please do NOT include the opening php tag, except of course if you're starting with a blank file
- add_action(
- 'AHEE_event_details_before_post',
- 'my_add_content_event_if_logged_in_registered',
- 11
- );
- function my_add_content_event_if_logged_in_registered( $post ) {
- if ( is_user_logged_in() && is_singular() ) {
- $user = wp_get_current_user();
- if ( ! $user instanceof WP_User ) {
- return;
- }
- //is there an attached EE_Attendee?
- $att_id = get_user_option( 'EE_Attendee_ID', $user->ID );
- if ( empty( $att_id ) ) {
- return; //bail, no attached attendee_id.
- }
- //grab contact
- $contact = EEM_Attendee::instance()->get_one_by_ID( $att_id );
- //if no contact then bail
- if ( ! $contact instanceof EE_Attendee ) {
- return;
- }
- // get events for this user
- $events = $contact->get_many_related( 'Event' );
- // build an array of event IDs
- foreach ( $events as $event ){
- $user_event_ids[] = $event->get( 'EVT_ID' );
- }
- // get this event's ID
- $this_event_id = $post->ID;
- // look for a match
- if( in_array( $this_event_id, $user_event_ids ) ) {
- echo '<h3>You\'ve been here before!</h3>';
- } else {
- echo '<h3>Welcome ' . $user->user_nicename . ', please register.</h3>';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement