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
- I’ve added SKU to Woocommerce permalinks, but I have small issue
- How to use a frontend URL with a Plugin
- Replace existing content from specific WooCommerce admin orders list column
- WordPress template_include filter not working properly
- Woocommerce – How to get products which have a sale between 20% to 40%? [closed]
- “The plugin generated 2694 characters of unexpected output…” on Plugin activation, CREATE TABLE sql command not working
- How to display a value from a radio button in the options menu in wordpress
- Woocommerce filter cart and category specific quantity [closed]
- How to get woocommerce cart content without an action?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- How to call function at the bottom of post using plugin?
- Woocommerce product download URL
- Limiting woocommerce line_total decimal length
- How can I use wp_query to show all product data using just the products ID?
- WP add_action factory
- Get stock by custom meta field on all Woocommerce variable products
- Set a condition based on WooCommerce checkout city field while placing order
- Swapping wp_dropdown_categories function with wp_category_checklist
- How to show phpinfo() only in a new tab?
- Call global variable array() in woocommerce child/template
- Remove price from Woocommerce variable product dropdown menu
- How can I remove a function that has been added to wordpress with add_filter?
- Get and insert order email address to the PHP template inside HTML text
- If no products are on sale – hide ID or class
- do search in two site and show the result in first site
- Changes in permalink structure in WordPress and how to apply to in-site links
- How can I pass a custom/dynamic product to the Woocommerce cart?
- Extend PHP regex to cover “srcset” and “style” attributes
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- How to use html inside a functions.php code?
- get_template_directory_uri() providing wrong path for img
- plugin add action hook is not working :
- zip unzip attachments in wordpress
- Scheduling an event inside plugin class is not working
- How to upload WP user avatar on woocommerce account page [closed]
- Only show size attributes in product box woocommerce when available
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- WooCommerce “Checkout Now” button [closed]
- WordPress theme showing blank page
- PHP: How to access db the right way in plugin?
- WordPress – Get Posts with Category data
- How to use wp_send_json() and output the value with ajax?
- Woocommerce. Get a list of products in the current category on the archive page and product page
- Is it possible to access admin-ajax.php using PHP?
- Call to “admin_notices” hook from a static method
- How to Create custom block for displaying information in content section which act like shortcode
- How to detect and handle the time difference between server and user in WordPress?
- How to setup the Email piping in WordPress plugin?
- Getting an error when my plugin is updated, but the files update correctly
- How to hide a div section when user is logged in, in single product woocommerce
- Remove span tags from WooCommerce Downloads page
- Global variable doesnt’t pass to another function
- Exclude category from woocommerce product category list
- Edit woocommerce_product_archive_description using hook
- Constant expression contains invalid operations plugin class properties visibility
- How to create loop inside wordpress function?
- How to auto-generate random numbers in username?
- Remove generated category and tag class names from woocommerce product & blog listings markup
- Unable to pass variable to database
- Gravity Forms Marketo Plugin Feed [closed]
- Add custom filter to register data in array
- Trouble using wordpress functions in a pop-up modal form
- MySQL update text field with ‘
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- How to find the value of the user password in wordpress and send it to another server via rest api
- Change Checkout “Place Order” text if cart has a specific product
- display php code in header using wp_head()
- Variable ++ in query loop
- WooCommerce Checkout Cart [closed]
- WordPress REST API – Custom field not added to pages
- Woocommerce – add tracking code to another email template
- How to change product title color in shop page if product has specific product tag (Woocommerce)?