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