Extend Woocommerce rest api routes fails

What if in your register_rest_route() call you can pass it the permission_callback option: ‘permission_callback’ => function () { return current_user_can(‘customer’); // OR return current_user_can(‘shop_manager’); } That way you are sure that you are dealing with a logged in Woocommerce user?? These are the two roles that Woocommerce is adding to your site. https://docs.woocommerce.com/document/roles-capabilities/ I know … Read more

How can I remove categories in menu in custom post type?

This was hacked together very quickly. I don’t for sure if there will be problems with translation, but I be there would be. function remove_menu_from_cpt() { global $submenu; $post_type=”book”; $tax_slug = ‘post_tag’; if (isset($submenu[‘edit.php?post_type=”.$post_type])) { foreach ($submenu[“edit.php?post_type=”.$post_type] as $k => $sub) { if (false !== strpos($sub[2],$tax_slug)) { unset($submenu[“edit.php?post_type=”.$post_type][$k]); } } } } add_action(“admin_menu’,’remove_menu_from_cpt’); It used … Read more

Custom Fields Bulk Edit

FIRST BACKUP!!!!! NEXT, BE SURE THE BACKUP IS RIGHT Now, you can use this code in PHPMyAdmin UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, ‘preview’, ‘edit’) WHERE meta_key = ‘dp_video_code’ Make sure that’s the correct name of the custom field, you can check it in the wp_postmeta table.

How to create different menu’s for not logged in visitors and for logged in members?

You can do that by using 2 different menus (wp_nav_menu). use is_user_logged_in conditional tag and apply a different menu accordingly: if (is_user_logged_in()) { wp_nav_menu(array(‘theme_location’ => ‘logged_user’ )); } else { wp_nav_menu(array(‘theme_location’ => ‘new_user’ )); } Edit This code goes where you’d usually put your regular menu in the theme – probably header.php Also, make sure … Read more

How to rotate the header image per day?

<div id=”header”> <?php mt_srand((int)date(‘z’)); $headers=glob(PATH_TO_FILES .’/*.jpg’); $header=mt_rand(0,count($headers)-1 ); ?> <img id=”header-image” `src=”https://wordpress.stackexchange.com/questions/5232/<?php echo URL_TO_FILES .”https://wordpress.stackexchange.com/”.basename($headers[$header]); ?>” alt=”header” /> </div> replace your current header with this. I will of course help you implement this further if you need help. (or if you need the code explained)