wordpress - How to hide or block the WooCommerce generated pages? -
When activating WooCommerce, the plugin generates some pages responsible for the output of the store's functionality. All is well, except I have some opportunities where a person removes this page from the customer or on his behalf. They look like empty pages.
Is there no way I can stop this, by hiding them from the customer (shop manager role) or blocking further versions?
This is the solution that will automatically collect the ID of pages generated by Woocommerce. The plugin creates four pages (shop, cart, checkout, my account) on the installation, and saves the IDs of those pages in that code under the wp_options table. Options are:
woocommerce_shop_page_id woocommerce_cart_page_id woocommerce_checkout_page_id woocommerce_myaccount_page_id for example, collects IDs action (before that runs the actual query is executed) within automatically if Wartm Users are not a admin is not WC will be unable to recover the generated pages.
The second part is to disable the edit page link in the admin bar . Because the logged user still has direct access to pages through the admin bar, because the action was done to remove the edit page link, only for the first part of the DCC pages. goes.
Put this in code> functions.php , or to create a plugin if you want the theme independent solution.
ADD_ACTION ( 'pre_get_posts', function ($ query) {if (is_admin () || $ query- & gt ;! is_main_query ()) back global $ pagenow, $ post_type, if ($ pagenow == 'edit.php' & amp;! & amp; $ post_type == 'page' & amp; & amp; in_array ( 'admin', wp_get_current_user (in) - & gt; roles)) {$ out = array_map (function ($ item) {return Get_option ($ item);}, array ( 'woocommerce_shop_page_id', 'woocommerce_cart_page_id', 'woocommerce_checkout_page_id', 'woocommerce_myaccount_page_id')); $ Query- & gt; set ('post__not_in', array_filter ($ out));}}); Add_action ( 'wp_before_admin_bar_render', function) (if (is_admin () || | is_page ()) return; global $ wp_admin_bar; $ exclude = array_map (function ($ item) {return get_option ($ item);}, array ( ' (If_array (get_queried_object () -> ID, $ Excluded) & amp;! In_array ('admin', wp_get_current_user () -> ; Roles)) $ wp_admin_bar- & gt; remove_menu ('edit');}); These are some links that have helped me:
< / P>
Comments
Post a Comment