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
- Include WP_Query in my own PHP file?
- How to get Woocommerce Variation ID? [closed]
- Resize Image without cropping
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- How to display product cropped thumbnail (150×150) for WooCommerce product categories
- Add to checkout total lines an additional line below shipping in WooCommerce
- When is is_admin() available?
- How To Change The Html of Products filtration sidebar in Woocommerce?
- How To add custom radio boxes to WooCommerce Billing page and change total price by this field?
- WooCommerce: update custom fields after checkout validation failure
- Trigger Woocommerce New User Email
- Inject PHP code into “sidebar-content” – code before my WooCommerce sidebar widget?
- wp_loaded hook block script enquequing
- Custom filter in admin edit custom post type responding with invalid post type?
- How to find error in my code when the error message is pointing to WP core file?
- How to access global variable $menu inside a class function
- How to upload a file to a folder named after the user_id via plugin
- WooCommerce Webhooks not firing because of error in wp-includes/meta.php
- developing a wordpress plugin, have a few PHP Woocommerce related coding questions
- adjust section according to country?
- Sum the total amount of a specific product purchased per user and display in table
- Woocommerce change prices for a certain country [closed]
- What exactly do this function declared into functions.php file of a WP theme?
- How to use html inside a functions.php code?
- WordPress Environment: Dynamic Page using shortcode – how to change the page name for sharing
- zip unzip attachments in wordpress
- wordpress admin plugin menu custom css
- How to upload WP user avatar on woocommerce account page [closed]
- How to Change CSS Colors from Custom Plugin Settings Page
- How to relocate paypal button gateway on checkout page in woocommerce
- Passing the name of selected color from the custom component to `render_callback`
- wordpress frontend editor to add extra css to website
- How do I run code every 24 hours?
- Woocommerce Product_cat for current category page
- PHP: How to access db the right way in plugin?
- select a single val though a table in wordpress
- 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
- How can I enter on the Thank you page in woocommerce the discount code I assigned to the product category?
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Woocommerce append shipping method form
- How to detect and handle the time difference between server and user in WordPress?
- How to setup the Email piping in WordPress plugin?
- Allow two posts (from different categories) to have the same slug
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Reliable way to add nonce to HTTP Header in WordPress?
- Getting an error when my plugin is updated, but the files update correctly
- Creating a POP Alert
- How do I check if a product is in two categories?
- php code for outputting a custom page in my account
- Remove span tags from WooCommerce Downloads page
- WordPress Plugin Development – get_option error
- how to add new PHP page in WordPress plugin
- How can I get my WordPress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?
- Edit woocommerce_product_archive_description using hook
- Constant expression contains invalid operations plugin class properties visibility
- Gutenberg blocks shortcodes compatibility
- Save custom field on WP_List_Table
- How to empty price of simple and variable product when product changed into out off stock
- Load script and styles using an array of resources
- How to create loop inside wordpress function?
- Input field duplicates on form submit by jQuery
- How to echo a PHP code into WooCommerce variation product?
- Get Billing Email from WooCommece Checkout and Pass to Fullstory JS
- Woocommerce custom attributes list help
- Change pricing in Woocommerce based on Category and Product [closed]
- Global filter not working
- WooCommerce remove_action and add_action [closed]
- Gravity Forms Marketo Plugin Feed [closed]
- How to add margin underneath woocommerce total price amount -> productpages
- 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()
- why css file not link?how to create permalink?
- ajax problems on loading page [closed]