you can not, and should not be able to write to files directly. You need to use the wordpress filesystem api https://codex.wordpress.org/Filesystem_API which either requires a pre configuration on the site or user manual control.
In addition it is just wrong to automatically write anything into wp-config.php
as any mistake will bring down the site with no way to recover except for recovering from backup which is rarely an easy process.
Related Posts:
- explanation for activate_plugin function in wordpress core
- Unable to activate wordpress importer after installing it
- Prevent a plugin from being automatically activated
- How can I use WordPress functions in my stylesheet?
- Customizing subject in comment notification e-mails
- WP showing “warning: call_user_func_array()”, What to do?
- How can I pass a variable to wp_ajax action?
- Activate Plugin which is in subfolder?
- How can i change an image’s author?
- Multisite: Activate plugin for subsites only?
- WP-Members redirect if member ALREADY logged in
- How to edit/delete single row items in a table on my own menu page
- how to include a simple jquery file into a wordpress plugin
- How to get subscription key or id using Woocommerce Subscriptions [closed]
- How to get member list based on role by using buddypress?
- How to Include a Loop Template File in a Plugin
- get shortcode value
- Storing Options in a Shortcode
- How can I get WordPress to save comments in markdown format?
- Add Product Subtitle to Woocommerce Product Page
- Plugins Page invisible / white
- How to block plugin activations with no known user or coming from unknown IP address range?
- code is working properly in Core PHP but writing coding in WordPress
- Custom WPBakery elements not displaying in WP admin
- How can I fix the mixed content problems of the kk star ratings plugin?
- Basic Object Oriented plugin question
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- All sites themes functions.php have been changed
- WordPress + PHP + IIS + PHP Fatal error: require():
- admin-ajax.php warning max input vars exceeded on layered pop plugins [closed]
- Individual testimonial taxonomy not displaying (white screen)
- Adding regex filter to feedwordpress
- Perform internal redirect in WordPress?
- How to prevent plugins from loading jQuery
- Media Upload Tab reload and change $_GET
- Change get_current_user_id code to the author’s profile
- How to define constant before plugin [duplicate]
- Duplicate results are displayed in a custom plugin [closed]
- Notice: Uninitialized string offset: 0 in social sharing mu-plugin
- php code crashes site – possible syntax error
- Basic function call on init failing
- Help with WP Business Directory Manager Plugin?
- How to redirect to same page after form submission
- I receive taxonomy id
- Is there a way to convert shortcodes to html content?
- Loop in elementor custom widget not working
- Change text string in a plugin
- get_users(); Is an Undefined Function When Used in Cron Job
- the_content() printing DOCTYPE, and tags in the middle of page
- How to add a new column with text fields to WooCommerce Cart List?
- How to change WooCommece variation data programmtically [closed]
- How to include files relative to a file’s directory
- .php file for woocommerce edit category? [closed]
- Asynchronous request in wordpress
- dynamically create callback functions inside a for loop
- Custom meta box with jQuery.sortable custom post type list
- Passing value as hidden parameter to next page
- WordPress truncate posts question (plugin related)
- Different registration form for different roles
- Apply html elements in php statement
- My plugin does not install correctly if a previous version is still installed
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- Get product categories and add them to a custom taxonomy
- Use a hook or filter, or overwrite this Gamipress function?
- How do I display PHP file contents on front end of WordPress?
- add_rewrite_rule to load different page, without changing URL in browser
- How to run flush_rewrite_rules on activation after i register my custom post type using WordPress Boilerplate Plugin
- How can I translate something in my class constructor of my plugin in WordPress?
- Define global variable in theme file and call that variable in plugin file
- Adding discount functionality to the cart
- Precheck fields when I add a new post
- SimpleXML is not working with xml response from external api
- Multiple image selection custom widget
- How To Toggle User_Meta in frontend in a form using PHP
- Change Woo Custom Endpoint Titles from a Plugin
- No result after wpdb->insert
- How can I store user preferences in WordPress and retreive them later?
- Cannot pass variable to page definition
- Plugin debugging with errors in activation routine
- Number format in thousands on highcharts in wpdatatable plugin
- How do I change tab url
- Populate select option with JSON file
- API calls on plugin activation or init?
- Things that saved lose when logout
- How to speed up installing plugins and upgrading WordPress
- W3 Total Cache Can’t Really Detect Things
- Different plugins activated online and offline
- PHP and Jquery pass value from form. Update function on DataBase
- How do I add php to all links automatically?
- update_post_meta not working
- Pulling Advanced Custom Fields from other pages
- Plugin use of ajax/jquery depending dropdown
- Unable to show 4 products in a row
- WordPress portfolio pagination on home page
- How to add custom html to the Media > Attachment Details modal?
- Refresh server side rendered block in Gutenberg without changing attributes or its content
- I want create woocommerec match products columns
- WordPress Custom Page Blog Template Pagination Problem (Pagination Not Displaying)
- How to override plugin function in code snippets WordPress
- How to create a “Most Popular” & “Latest” TAB in WordPress