abstract pos

Home Forums Calendar Products Events Calendar PRO abstract pos

Viewing 13 posts - 16 through 28 (of 28 total)
  • Author
    Posts
  • #1396177
    George
    Participant

    Hey @martin75,

    Did you try creating the example_update_instructor() and example_create_instructor() functions that Cliff mentioned earlier in this thread, using the file for reference that he mentioned?

    Thank you for your kind words and patience here.

    — George

    #1400672
    martin75
    Participant

    Hi george , sorry for the dealy replying , sick new born baby took prioity! ,
    here is where im at exactly.
    in my functions.php i have the following code , this is the only modification i have made.

    register_post_type( 'instructors', array(
        'labels'  => array(
            'name'                    => 'Instructors',
            'singular_name'           => 'Instructor',
            'singular_name_lowercase' => 'instructor'
        ),
        'public' => true
    ));
     
    function tribe_link_instructors_to_events() {
        tribe_register_linked_post_type( 'instructors', array(
    	    'singular_name'           => 'Instructor',
    	    'singular_name_lowercase' => 'Instructor',
    	    'allow_multiple'          => true,
    	    'allow_creation'          => true
    	) );
    }
     
    add_action( 'init', 'tribe_link_instructors_to_events' );
    
    /**
     * Modify the form for "Instructors" on the events edit screen.
     *
     * @param string $post_type The post type whose form is being modified.
     */
    function tribe_modify_the_instructors_form_on_events( $post_type ) {
    
    	// We only want the "Instructors" post type; bail if it's some other post type.
    	if ( 'instructors' !== $post_type ) {
    		return;
    	}
    
    	// Add a Table Row for the Instructor Website to show up below the Instructor Name.
    ?>
    	<tr class="linked-post">
    		<td>Instructor Website:</td>
    		<td>
    			<input type='text' tabindex="<?php tribe_events_tab_index(); ?>" name='linked_instructors[website][]' class='linked-post-website instructors-website' size='25' value='' />
    		</td>
    	</tr>
    
    	<tr class="linked-post">
    		<td>Instructor Website 2:</td>
    		<td>
    			<input type='text' tabindex="<?php tribe_events_tab_index(); ?>" name='linked_instructors[website_2][]' class='linked-post-website-2 instructors-website-2' size='25' value='' />
    		</td>
    	</tr>
    <?php
    }
    
    add_action( 'tribe_events_linked_post_new_form', 'tribe_modify_the_instructors_form_on_events' );
    
    /**
     * Saves the instructor information passed via an event.
     *
     * @param int|null $id ID of instructor
     * @param array $data The instructor data
     * @param string $post_type The post type
     * @param string $post_status The intended post status
     *
     * @return mixed
     */
    function tribe_save_the_instructors_form_on_events( $id, $data, $post_type, $post_status ) {
    
    	// Check to see if we're updating an already-existing instructor post.
    	if ( isset( $data['id'] ) && intval( $data['id'] ) > 0 ) {
    
    		// We're updating an existing post, but only an ID was passed; no other data.
    		// So, just return the ID. Do nothing.
    		if ( count( $data ) == 1 ) {
    			return $data['id'];
    		}
    
    		// Check out the Tribe__Events__Organizer->update() method for inspiration on how to make an "update" function.
    		return example_update_instructor( $data['id'], $data );
    	}
    
    	// Otherwise, we're not updating an existing instructor; we have to make a new instructor post.
    	
    	// Check out the Tribe__Events__Organizer->update() method for inspiration on how to make a "create" function.
    	return example_create_instructor( $data, $post_status );
    }
    
    add_action( 'tribe_events_linked_post_create_instructors', 'tribe_save_the_instructors_form_on_events', 10, 4 );

    this results in the following.
    on the left panel in wordpress dashboard i have an instructor tab (see image for_george)
    i can click on this and it opens a sub menu , instructors and add new.

    if i select add new , all i can do is type in title and also theres the standard wordpress text box , no other fields are present for me to create/edit or type in.

    if i type in a title and hit publish then it is saved , but just a title. see image (for_george_2.jpg)

    from here if i goto add new event i have the following boxes (for_george_3.jpg)
    if i clcik on the box i get the following (for_george_4.jpg)
    so far the instructor field within add event works as expected,i can select previously created instructors and if i type in to create i then get the 2 boxes to type into (for_george_5.jpg)

    so far so good when i hit publish the event , it doesn’t get published , and i am presented with a blank white page.

    i hope that clears it up , i am presuming its because the functions example.etcetc dont exist , do these need to be added to the single.event.php in some way , its so close but for me and my knowledge its a long long way away!! the more i look into it and read this post back the more confused i become (i even printed it out ) :-0), it really is driving me mad, this simple field would drive new and repeat visitorss to my site.

    as always thanks for your time , have a great day ,
    p.s it acts the same way in 2012,13,14,15,6 and 2017 with just the events and pro plugins active

    #1400678
    martin75
    Participant

    heres the 5th image , was capped to 4 sorry

    #1402257
    martin75
    Participant

    ok george i think it all works as it should up to this point i note in previous post this

    Let us know if that helps at least get the “Create or Find” dropdown working!

    As cliff noted, the “create” and “save” functions themselves are ones you’ll have to create, but I can offer some insight on that once we confirm the “Create or Find” dropdown is working for the Instructors linked post type…

    …let us know what you find!

    — George

    so as i see it now thats where its up to . could you offer this insight into these functions?

    thanks again

    #1404056
    martin75
    Participant

    ok george i think it all works as it should up to this point i note in previous post this

    Let us know if that helps at least get the “Create or Find” dropdown working!

    As cliff noted, the “create” and “save” functions themselves are ones you’ll have to create, but I can offer some insight on that once we confirm the “Create or Find” dropdown is working for the Instructors linked post type…

    …let us know what you find!

    — George

    so as i see it now thats where its up to . could you offer this insight into these functions?

    thanks again

    #1404109
    George
    Participant

    Hey Martin,

    Apologies for the delayed response.

    As noted earlier, we cannot help with custom coding. I am glad we were able to help with custom coding thus far despite that policy, but you will have to take the reins from here.

    With that being said, as one final bit of help, I would like to highlight that you have to create the example_update_instructor() and example_create_instructor() functions.

    They currently don’t exist in the sample code you have shared thus far, so your task from here is to make them exist.

    There are some existing functions in our own code that you can use as inspiration. For example, here’s an “Update” function for Organizers that you could use to learn from for Instructors: https://github.com/moderntribe/the-events-calendar/blob/4.6.5/src/Tribe/Organizer.php#L417-L486

    Despite our custom coding policies, I have written more custom code for you herehttps://git.io/vbge8

    Please look at the two new functions at the bottom of the file, example_update_instructor() and example_create_instructor().

    Using this updated code should work well for you. If it does not or other issues persist, you will unfortunately have to take the reins on further refinement and development of your custom features here.

    Best of luck with your project,
    George

    #1404181
    martin75
    Participant

    many many thanks george for your time and effort, unfortunately its not quite right , can you please answer a few questions for me to help me along ??i dare not ask you to do any more coding!! 😉
    1) i try to create the instructor when adding event and i end up on a white screen and the event is never published all i can do is press back button.
    2) i use a previously created instructor and the event is posted successful. how ever on the single event page there is no mention of instructor , should there be ? or do i need to add something to single-event.php to display the instructor details ?
    3) when i get this all working can i click on an instructor like i can venue and organizer and it shows all the upcoming events for this instructor ?

    its so close now !! thx george

    #1405064
    Cliff
    Member

    Martin, I haven’t followed along each reply between you and George, but we have reached the limit of support we’re able to provide to you. As you probably know already, we don’t provide customizations for customers, per our Scope of Support / Terms.

    If you need further coding help, you may want to reference our documentation and list of known customizers.

    #1405071
    martin75
    Participant

    cliff i appreciate all you have done to help me !i dont want any more help coding just 3 little answers so i have something to work towards!! if you could spare 30 seconds to answer i would be eternally grateful simple yes and no will suffice!!
    thanks again martin !!

    #1405143
    Cliff
    Member

    Rereading your previous reply:

    If you ever see a white screen in WordPress, I always recommend for you to enable WP_DEBUG and WP_DEBUG_LOG (which will create a file on your server at /wp-content/debug.log if there are any WP_DEBUG messages) and share any debug messages you see.

    Once a linked post type is properly registered, it should work just like Organizers and Venues do.

    However, you’ll need to alter the template(s) in order to get such information to display. For this information, please reference our Themer’s Guide.

    #1405365
    martin75
    Participant

    many thanks cliff, i think you haveprovided me with more than enough to get this up and running , please accept my thanks!!
    kind regards martin

    #1405446
    Cliff
    Member

    Excellent! So glad we could go above-and-beyond for you in this one, and thanks to you for pointing out that our Knowledgebase article needs some love. We’ll eventually get to that.

    Have a great rest of your week!

    #1481500
    Cliff
    Member

    Hi, Martin.

    Good news! We’ve significantly modified our Knowledgebase article about Linked Post Types (previously called Abstract Post Types).

    We’ve even provided a working example plugin to get you started.

    Please review it afresh at https://theeventscalendar.com/knowledgebase/linked-post-types/ and open a new support thread if you have any follow-up questions.

    Thanks!

Viewing 13 posts - 16 through 28 (of 28 total)
  • The topic ‘abstract pos’ is closed to new replies.