Capability problems on CPT Tickets

Home Forums Ticket Products Event Tickets Plus Capability problems on CPT Tickets

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1086646
    Robert
    Participant

    Hi,

    I’m working on a site where I need to sell tickets for a Custom Post Type (CPT).
    I set up the plugin but it’s not saving the tickets because of a php error.

    CPT:
    https://gist.github.com/bokorir/2172ae0127cd7480003d

    I’m getting an error about:
    Notice: Undefined offset: 0 in /srv/www/domain.com/current/web/wp/wp-includes/capabilities.php on line 115

    This happens because in your Tribe__Tickets__Tickets->has_permission( ) you are checking the capability in a bad way. (I guess)

    		$cap = "edit_{$post->post_type}";
    			if ( 'post' === $post->post_type || 'page' === $post->post_type ) {
    				$cap .= 's';
    			}

    So my post type has registered with a singular name tp_course (how it should be by default) and you check the edit_{$post->post_type} wich is edit_tp_course in this case. But to check this permission (edit_post => edit_tp_course) you have to add another argument which is the post id.

    http://wordpress.stackexchange.com/a/84205/81135

    So I would change your code to the following:

    https://gist.github.com/bokorir/b07622dd2a462aa7b8c7

    In this way you would always check for the right capability.

    What do you think?

    Thanks,

    Robert

    #1087448
    Cliff
    Member

    Hi Robert. Thanks for sharing.

    I had one of our developers take a look and they said it seems reasonable at first glance. They asked if you could submit a pull request at https://github.com/moderntribe/event-tickets

    Would you be able to?

    #1087645
    Robert
    Participant

    Hi,

    It’s done.

    Robert

    #1088013
    Cliff
    Member

    Thanks!

    I found it at https://github.com/moderntribe/event-tickets/pull/136 and gave the heads up to one of our developers.

    I’ll mark this thread as Closed for now.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Capability problems on CPT Tickets’ is closed to new replies.