Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */
- function register_new_tony_shortcodes( $shortcodes, EE_Shortcodes $lib ) {
- //Add a shortcode to be used with the EE Datetimes within messages
- if ( $lib instanceof EE_Datetime_Shortcodes ) {
- //Add your shortcode to the add as the key, the value should be a description of the shortcode.
- $shortcodes['[EVENT_URL_GENERATE]'] = _('The shortcode to generate the access url');
- }
- //Add a shortcode to be used with the EE Event List within messages
- if ( $lib instanceof EE_Event_Shortcodes ) {
- //Add your shortcode to the add as the key, the value should be a description of the shortcode.
- $shortcodes['[EVENT_URL_GENERATE]'] = _('The shortcode to generate the access url');
- }
- //Return the shortcodes.
- return $shortcodes;
- }
- add_filter( 'FHEE__EE_Shortcodes__shortcodes', 'register_new_tony_shortcodes', 10, 2 );
- function register_new_tony_shortcodes_parser( $parsed, $shortcode, $data, $extra_data, EE_Shortcodes $lib ) {
- //Check for the datetime shortcodes as that's were we added the custom shortcode above
- //also check that $data is the expected object (in this case an EE_Datetime)
- if ( $lib instanceof EE_Datetime_Shortcodes && $data instanceof EE_Datetime ) {
- //Then check for our specific shortcode
- if ( $shortcode == '[EVENT_URL_GENERATE]' ) {
- //Do whatever you need to do here and return the value for that specific datetime.
- return $data->ID();
- }
- }
- if ( $lib instanceof EE_Event_Shortcodes )
- {
- //Then check for our specific shortcode
- if ( $shortcode == '[EVENT_URL_GENERATE]' )
- {
- //global $wpdb;
- //First check we have an event object.
- $event = $extra_data instanceof EE_Event ? $data : null;
- $aee = $extra_data instanceof EE_Messages_Addressee ? $data : NULL;
- if ($aee !== null) return $aee; else return 'Object not Found';
- $primary_reg = $aee->primary_reg_obj;
- $prmary_attendee = $aee->primary_att_obj;
- if( $primary_reg instanceof EE_Registration )
- {
- //Is a valid EE_Registration object, do something with it here.
- }
- if ( $primary_attendee instanceof EE_Attendee )
- {
- //$primary_attendee is a valid EE_Attendee object, as it's the primary
- //attendee object you can pull the email from it.
- $primary_att_email = $primary_attendee->email();
- return 'Result ' . $primary_att_email;
- }
- //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead.
- /*if ( empty( $event ) )
- {
- $aee = $data instanceof EE_Messages_Addressee ? $data : NULL;
- $aee = $extra_data instanceof EE_Messages_Addressee ? $extra_data : $aee;
- $event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration ? $aee->reg_obj->event() : NULL;
- $event_att = $aee instanceof EE_Messages_Addressee && $aee->att_obj instanceof EE_Attendee ? $aee->att_obj->email() : NULL;
- $primary_reg = $aee->primary_reg_obj;
- $primary_attendee = $aee->primary_att_obj;
- if ( $primary_attendee instanceof EE_Attendee )
- {
- //$primary_attendee is a valid EE_Attendee object, as it's the primary
- //attendee object you can pull the email from it.
- $primary_att_email = $primary_attendee->email();
- $message = 'This is a valid attendee object<br/>';
- }
- else
- {
- $message ='could not find attendee object<br/>';
- }
- $message .= 'Result : <br/> test - '. print_r($aee,true);
- //$result = $wpdb->get_var('SELECT ATT_EMAIL FROM ');
- wp_mail('john-henry@dieselbrook.co.za', 'Debug' , $message);
- return $message;
- }
- //Check we do now actually have the event object.
- if ( !empty( $event ) ) {
- //return $page_id;
- //}
- }
- }
- //If not within the correct section, or parsing the correct shortcode,
- //Return the currently parsed content.
- return $parsed;
- }
- add_filter( 'FHEE__EE_Shortcodes__parser_after', 'register_new_tony_shortcodes_parser', 10, 5 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement