Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Use %store% in Products' permastructure settings
- */
- function pm_dokan_store_field($default_uri, $native_slug, $post, $slug, $native_uri) {
- // Do not affect native URIs
- if($native_uri == true || empty($post->post_type) || $post->post_type !== 'product') { return $default_uri; }
- if(strpos($default_uri, '%store%') !== false) {
- $store_name = get_user_meta($post->post_author, 'dokan_store_name', true);
- $default_uri = str_replace('%store%', sanitize_title($store_name), $default_uri);
- }
- return $default_uri;
- }
- add_filter('permalink_manager_filter_default_post_uri', 'pm_dokan_store_field', 3, 5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement