{"id":1086646,"date":"2016-03-09T07:05:18","date_gmt":"2016-03-09T15:05:18","guid":{"rendered":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/"},"modified":"2016-03-11T14:39:41","modified_gmt":"2016-03-11T22:39:41","slug":"capability-problems-on-cpt-tickets","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/","title":{"rendered":"Capability problems on CPT Tickets"},"content":{"rendered":"<p>Hi,<\/p>\n<p>I&#8217;m working on a site where I need to sell tickets for a Custom Post Type (CPT).<br \/>\nI set up the plugin but it&#8217;s not saving the tickets because of a php error.<\/p>\n<p>CPT:<br \/>\nhttps:\/\/gist.github.com\/bokorir\/2172ae0127cd7480003d<\/p>\n<p>I&#8217;m getting an error about:<br \/>\nNotice: Undefined offset: 0 in \/srv\/www\/domain.com\/current\/web\/wp\/wp-includes\/capabilities.php on line 115<\/p>\n<p>This happens because in your Tribe__Tickets__Tickets-&gt;has_permission( ) you are checking the capability in a bad way. (I guess)<\/p>\n<pre><code>\t\t$cap = &quot;edit_{$post-&gt;post_type}&quot;;\n\t\t\tif ( &#039;post&#039; === $post-&gt;post_type || &#039;page&#039; === $post-&gt;post_type ) {\n\t\t\t\t$cap .= &#039;s&#039;;\n\t\t\t}<\/code><\/pre>\n<p>So my post type has registered with a singular name tp_course (how it should be by default) and you check the edit_{$post-&gt;post_type} wich is edit_tp_course in this case. But to check this permission (edit_post =&gt; edit_tp_course) you have to add another argument which is the post id.<\/p>\n<p>http:\/\/wordpress.stackexchange.com\/a\/84205\/81135<\/p>\n<p>So I would change your code to the following:<\/p>\n<p>https:\/\/gist.github.com\/bokorir\/b07622dd2a462aa7b8c7<\/p>\n<p>In this way you would always check for the right capability.<\/p>\n<p>What do you think?<\/p>\n<p>Thanks,<\/p>\n<p>Robert<\/p>\n","protected":false},"template":"","class_list":["post-1086646","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Capability problems on CPT Tickets -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Capability problems on CPT Tickets -\" \/>\n<meta property=\"og:description\" content=\"Hi, I&#8217;m working on a site where I need to sell tickets for a Custom Post Type (CPT). I set up the plugin but it&#8217;s not saving the tickets because of a php error. CPT: https:\/\/gist.github.com\/bokorir\/2172ae0127cd7480003d I&#8217;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 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/\" \/>\n<meta property=\"article:modified_time\" content=\"2016-03-11T22:39:41+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/\",\"name\":\"Capability problems on CPT Tickets -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2016-03-09T15:05:18+00:00\",\"dateModified\":\"2016-03-11T22:39:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Ticket Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Event Tickets Plus\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Capability problems on CPT Tickets\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Capability problems on CPT Tickets -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/","og_locale":"en_US","og_type":"article","og_title":"Capability problems on CPT Tickets -","og_description":"Hi, I&#8217;m working on a site where I need to sell tickets for a Custom Post Type (CPT). I set up the plugin but it&#8217;s not saving the tickets because of a php error. CPT: https:\/\/gist.github.com\/bokorir\/2172ae0127cd7480003d I&#8217;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 [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/","article_modified_time":"2016-03-11T22:39:41+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/","name":"Capability problems on CPT Tickets -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2016-03-09T15:05:18+00:00","dateModified":"2016-03-11T22:39:41+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/capability-problems-on-cpt-tickets\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Ticket Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/"},{"@type":"ListItem","position":4,"name":"Event Tickets Plus","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/event-tickets\/event-tickets-plus\/"},{"@type":"ListItem","position":5,"name":"Capability problems on CPT Tickets"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1086646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1086646\/revisions"}],"predecessor-version":[{"id":1087446,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/1086646\/revisions\/1087446"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=1086646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}