Use your plugin activation hook to make the change. That will only run once, when your plugin is first activated, allowing the user to overwrite that change later (if they want to).
register_activation_hook( __FILE__, function () {
if ( $permalinks = get_option( 'woocommerce_permalinks' ) ) {
$permalinks['product_base'] = 'property';
update_option( 'woocommerce_permalinks', $permalinks );
flush_rewrite_rules();
}
});
If you want to always force the permalink settings, use the underlying WordPress hook pre_update_option_$option_name
:
function wpse_406568_woocommerce_permalinks( $permalinks ) {
$permalinks['product_base'] = 'property';
return $permalinks;
}
add_filter( 'pre_update_option_woocommerce_permalinks', 'wpse_406568_woocommerce_permalinks' );
…that will always override whatever setting the user used for product base when saving their WC permalink settings.
Related Posts:
- Use wc_enqueue_js only on specific pages – nested add_action
- woocommerce subscriptions – get expiration date [closed]
- Automated Cart Update With Alert Box Each Time
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to use $_GET function WordPress backend
- How to auto fetch customer details in Woocommerce in checkout page
- I want to add custom add to cart link [closed]
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Can a plugin redirect product page based on IF condition?
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- custom post type with role Vendor
- Woocommerce custom Plugin in wordpress [closed]
- Add a custom WooCommerce settings tab with sections
- Payment field disappears on custom Paypal plugin
- I am having errors with checkout on wordpress
- product_type_options get saved value [closed]
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- Looping through and combining calls to Woocommerce REST API
- How to import woocommerce custom fields data into another site?
- How do I remove an action hook inside a class that is called by another class?
- How keep woocommerce users separeted in multisite install and keep admins on network
- Custom field fetch error on woocommerce pdf invoice
- WordPress 6.1.1 UTF8 Slug Limit Increase
- Woocommerce Convert existing order to the cart
- How to change product SKU’s in bulk with a plugin
- Remove slug of multiple custom post types with and without hierarchical
- Woocommerce Payment Method Change
- I’ve added SKU to Woocommerce permalinks, but I have small issue
- How do I use the Simple HTML DOM Parser in plugin when other plugin already uses it?
- How to make custom total price reactive in navigation
- Query String being Removed Creating a Pagination Issue within a Custom Plugin
- PHP can I add line numbers to file_get_contents()
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- OrderItem get_total() returns lower value than $order_item->get_product()->get_price() * quantity
- Add htaccess rules with insert_with_markers at beginning of htaccess
- custom shortcode will not display the wrapped content
- Change description on specific WooCommerce product status change
- Add the Name of Products Ordered to Admin New Order Email WooCommerce
- Changing Woocommerce flat rate every nth number of items
- How to call function at the bottom of post using plugin?
- How to prevent those PHP variables from being cached on WordPress?
- Woocommerce product download URL
- How to select WooCommerce products by post_meta and order them
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Setting All Drafts to ‘exclude-from-catalog’ in WooCommerce
- Woocommerce – Filter Variable Products by Variation Attributes and Variations Regular Price
- Insert array data on plugin activation
- Will simple function names in a class structure conflict with other plugins?
- woocommerce – hide payment method in new order email
- Do my defines need to be unique?
- WordPress php filter admin_body_class not working
- Limiting woocommerce line_total decimal length
- Do changes to WordPress permalink custom structure affect old urls?
- Help with some php math in WordPress
- How to add a second ‘place order’ button in WooCommerce [closed]
- Instantiate class to be available to all plugin functions
- Common abstract class for plugins
- How to test nonce with AJAX – Plugin development
- What does $wpdb->get_row return?
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- How do I display a user’s previous orders as a select box option on a product?
- How do you add customer capability after Woocommerce purchase?
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- Change sign up fee in cart for subscription products WooCommerce
- How can I use wp_query to show all product data using just the products ID?
- WP add_action factory
- wp_loaded hook block script enquequing
- write custom woocommerce templates and forms
- combine Code 1 with Code 2
- WooCommerce – Reset quantity input field when variation changes
- WP nonce invalid
- get current product name in functions.php
- Get stock by custom meta field on all Woocommerce variable products
- Make the first item as default on Woocommerce product category items list
- Custom Text in WooCommerce Order Processing Email Based on Products
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- Set a condition based on WooCommerce checkout city field while placing order
- Get WooCommerce product details and transfer them to a custom DB table
- Same log message keeps on printing to debug.log file thousand of times
- tracking number field in Woocommerce order [closed]
- WordPress custom slug (endpoint) and compare all links
- WooCommerce Related Products by Attribute
- Adding Default Settings to Theme My Login plugin
- Image as Sales Badge
- Custom filter in admin edit custom post type responding with invalid post type?
- WordPress Scheduled Event Request Blocking
- How can i upload images in an admin page?
- Append HTML Using Shortcode
- Delete a WordPress transient from a shortcode on Page/Post update
- WooCommerce – Email admin with new user details
- Plugin CSS not enqueing
- Create onClick Event to Re-load a Widget
- Swapping wp_dropdown_categories function with wp_category_checklist
- Automatically remove a canceled order in Woocommerce
- Accessing the database from a plugin outside of action hooks
- Adding subdomain to home_url for “add_menu_page”
- How to show phpinfo() only in a new tab?
- How to find error in my code when the error message is pointing to WP core file?