abstract pos

Home Forums Calendar Products Events Calendar PRO abstract pos

Viewing 15 posts - 1 through 15 (of 28 total)
  • Author
    Posts
  • #1382065
    martin75
    Participant

    hi im having the exact same issue as this one here https://theeventscalendar.com/support/forums/topic/no-drop-down-after-adding-register_post_type-presenters-to-events-form/?loggedout=true

    i notice no answer on the post above hopefully you can help me !!

    #1382273
    martin75
    Participant

    create or find an instructor is not present as you see from the picture , so no way it can be saved ? timely response would be appreciated

    #1383163
    Cliff
    Member

    Hi again, Martin.

    Are you saying that you are following along with https://theeventscalendar.com/knowledgebase/abstract-post-types/ and registering a new “Instructors” linked post type and it’s not working for you?

    If yes, please provide me your entire code snippet to implement this and I’ll see how I can assist.

    #1383180
    martin75
    Participant

    also please note all plugins disabled except for the events calendar and pro , and themes 2014.15.16 and 2017 tried whilst plugins disabled.
    exactly that Cliff, i followed this , i also added this i had to take out a “)” on line 45 or i had syntax error.

    hope this adds the snippet correct !

    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][]' class='linked-post-website instructors-website' 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 );
    }
    • This reply was modified 6 years, 5 months ago by martin75.
    #1385177
    martin75
    Participant

    Hi Cliff did you manage a peak into this ? this is the one thing i really bought pro version for especially as it had a guide of how to accomplish it for a novice like myself , im literally waiting on this to publish my site. may thx in advance

    #1385250
    Cliff
    Member

    Sorry for the delayed response.

    The code you shared includes example_update_instructor(), which is an undefined function. As it says in the comments, you need to create your own version of it, and it points you to https://github.com/moderntribe/the-events-calendar/blob/4.6.5/src/Tribe/Organizer.php#L417-L486 as a reference of what example_update_instructor() should be like.

    #1385308
    martin75
    Participant

    so i would need to create the-events-calendar/src/Tribe/instructor.php for starters i take it cliffe?

    i would draw your attention to https://theeventscalendar.com/knowledgebase/abstract-post-types/ , especialy this piece here “Doing this before version 4.2 of The Events Calendar meant lots of extra custom coding, but since 4.2 you can add or remove event-related post types with just a few simple filters” i think this is a bit misleading i purchased the pro simply for this. at no pint have i managed to have a simple instructor box in the admin new event form that says create within the box. it now seems i need to be a doctor of .php rather than “but since 4.2 you can add or remove event-related post types with just a few simple filters” . very disapointed , i know now this will never be achieved. thanks for your time

    #1386843
    martin75
    Participant

    is that the end of the help here ?

    #1387415
    George
    Participant

    Hey Martin,

    Thanks for your patience over the weekend! Now that we’re back in action here on Monday, I can confirm that Cliff and I are looking into this a little bit more deeply. We’re testing your code and will get back to you ASAP with our findings.

    In the meantime, you asked this:

    so i would need to create the-events-calendar/src/Tribe/instructor.php for starters i take it cliffe?

    I would like to confirm with you that NO, you do not need to make (and should NOT make) such a file.

    You should indeed be able to create a useful “Linked Post” with our abstract post types system; if it’s failing, then there could be a bug here. We are testing and will get back to you ASAP.

    Stay tuned! 😀

    — George

    #1387431
    martin75
    Participant

    thank you for the update George very much appreciated.

    #1387456
    George
    Participant

    Hey @martin75, here are several notes on this issue after some tinkering on my end:

    • First of all, you are right about a syntax error in this Gist of example code I created a while back. I have edited the Gist so that it no longer has that syntax error. Sorry about that!
    • Next, a problem I noticed in your code is that you had two separate “website” fields per instructor: “Website”, and then “Website 2”. But in your code, they were using the same field name.
      • For example, the field name for “Website” in your code is linked_instructors[website][]
      • But the field name for “Website 2” in your code is also just linked_instructors[website][]
      • The field name for “Website 2” in your code is should be unique, so something like linked_instructors[website_2][] would work better
    • As an example, here’s a modified version of my example code that shows how to have your “Website” And “Website 2” fields working with the “Create or Find” dropdown → https://git.io/vF5v7

    So I would recommend replacing your existing tribe_modify_the_instructors_form_on_events() and tribe_save_the_instructors_form_on_events() functions with the ones in that new Gist I linked above.

    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

    #1387606
    martin75
    Participant

    Many many thanks george i really do appreciate your time and help , i have entered the foloowing into my functions file but in the instructor field there is no box atall next to instructors ive attatched screen shot , i must be missing something here!

    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' );
    
    /**
     * 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_eventsXXX( $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 );
    }
    
    /**
     * 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' );

    also in wordpress back end the instructor field on the left in the image attatched , is not within the events on the left , should it be ?

    thankyou

    • This reply was modified 6 years, 5 months ago by martin75.
    #1392797
    George
    Participant

    Hey Martin,

    Thanks for your patience with the slow response over the Thanksgiving Holiday here in the US and such.

    In regards to your code, this is the point where things get a little bit outside the scope of the support we can provide. As Cliff noted, we cannot help with custom coding here on the forums as per the terms of our support policy which you can read here.

    However, I’m still happy to try and offer some advice about where to go from here.

    • First of all, you have some unused functions there and this is partially my fault because in the Gist I shared above, I left that function with “XXX” in its name in place…this is confusing and I apologize about that. That “XXX” function is not meant to be used, and so in fact you’ll want to do something more like this Gist here. Sorry to share another code example, but the code in the Gist I share here absolutely works for me and so I would recommend replacing your existing code with that And seeing if it helps.
    • Next, keep in mind the things Cliff noted earlier about the “example_create_instructor()” and “example_update_instructor()” functions…these don’t exist and you have to create them, using the built-in examples Cliff cited in his replies above as a guide for doing that. The code will not fully work until these functions exist and work.

    So, please try replacing your code with the code from this new Gist I made for you. Sorry about the lack of clarity in that first one!

    Let us know if this updated Gist helps to get the dropdowns working.

    #1392799
    George
    Participant

    Hey Martin,

    Another quick note here: The dropdown is only for selecting Instructors.

    So please make sure you have existing Instructors on your site to “select from”. If you don’t, then no selection dropdown will show up, because there’s nothing to select! And so you’ll only see those creation fields…

    …just wanted to mention this. Do try the code from the updated Gist I shared with you, and then ensure that you have created some test Instructor post types, then let us know what you find!

    — George

    #1393105
    martin75
    Participant

    hi George many thanks for the update firstly i really appreciate it and i also fully understand about custom coding and am sure its not viable to do so!!

    i used the new gist in functions.php hers where im at . in the left pain of wp-admin i select instructor (it isn’t in the event section but stands alone) i can enter a title and then have the word press text/visual box to type whatever i like , i have no website box etc etc. regardless of this if i make 2 exaple instructors they are saved and published. if i now go to events i finally have create or select , i can select the 2 examles, but there are no other info except the name. ifi type a new name and click it i then have website boxes!! so close ey?? well if i make a test event and create a new instructor then hit publish i just get a white page and the event never gets published!! im presuming this has something to do with the example create instructor etc etc…. there isnt enough info available for me to continue this and i think its a lost cause unfortunately , such a shame . i feel with a better article it would be doable, an article start to finish with 2 demo fields functioning would be awesome for others as well as myself it has the makings of a wonderful feature!

    i really wouldn’t push on this but just for your feedback ill make a few comments for the sake of the events calendar rather than my own gain,and please don’t take the wrong way. i purchased the pro version for this feature alone (and if i don’t end up with it functioning i wont be asking for a refund as i feel the free version warrants a good donation from myself anyhow) the knowledge base article on abstract post is somewhat misleading , it also eliminates simple things that are both useful and needed, ie the very last post you made! with that included i could of been at this same stage weeks ago!!! and not wasted your time and effort!! i would suggest a rework of that knowledge base article to make it a whole lot clearer as for me its a bit more than easy with a few filters!!

    thanks again to both George and Cliff in your en devour to assist me

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