Add capabilities and fix form action
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 22 Jan 2016 16:14:08 +0000 (11:14 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 22 Jan 2016 16:14:08 +0000 (11:14 -0500)
Form action now set to the actual page url.
Adding post type capabilities for the CPT of glmcoupon.
Adding capabalities requried for the terms of the coupons.
Need to add the creation of the capability as it is not automatically
added by wordpress like the CPT are.

models/coupon.php
views/front/couponList.php

index db14ac5..86be705 100644 (file)
@@ -319,9 +319,19 @@ class glm_coupons_coupon
             'supports'        => array('title', 'editor', 'thumbnail', 'author'),
             'has_archive'     => true,
             'menu_icon'       => 'dashicons-products',
-            'capability_type' => 'post',
+            'capability_type' => 'glmcoupon',
+            'capabilities'    => array(
+                'edit_post'          => 'edit_glmcoupon',
+                'edit_posts'         => 'edit_glmcoupons',
+                'edit_others_posts'  => 'edit_others_glmcoupons',
+                'publish_posts'      => 'publish_glmcoupons',
+                'read_private_posts' => 'read_private_glmcoupons',
+                'delete_post'        => 'delete_glmcoupon',
+                'read_post'          => 'read_glmcoupon'
+            ),
+            'map_meta_cap'    => true,
             'hierarchical'    => false,
-            'rewrite'         => array('slug' => 'coupons'),
+            'rewrite'         => array('slug' => 'glmcoupons'),
             'taxonomies'      => array(GLM_COUPON_TAX_CATEGORIES),
             'show_in_menu'    => true,
             'show_ui'         => true,
@@ -412,7 +422,13 @@ class glm_coupons_coupon
             'query_var'         => GLM_COUPON_TAX_CATEGORIES,
             'rewrite'           => array('slug' => GLM_COUPON_TAX_CATEGORIES),
             'show_admin_column' => true,
-            '_builtin'          => true
+            '_builtin'          => true,
+            'capabilities'      => array(
+                'manage_terms' => 'manage_glmcouponterms',
+                'edit_terms'   => 'manage_glmcouponterms',
+                'delete_terms' => 'manage_glmcouponterms',
+                'assign_terms' => 'manage_glmcouponterms'
+            )
         ));
     }
 
index d599397..17bc2d1 100644 (file)
@@ -1,6 +1,6 @@
 <div>
     <h1>List Coupons</h1>
-    <form action="<?php bloginfo('siteurl');?>/coupon/">
+    <form action="<?php the_permalink()?>">
         <select name="glm_couponscategory" class="glm_coupon_search_select" method="post">
             <option value="">-- All Categories --</option>
         <?php if ($catSelect) : foreach ($catSelect as $catName) :?>