I work in a WordPress plugin. I create a custom form where the user adds values ββand then clicks the submit button. When the user clicks the Submit button, he is redirected to the user process file, where I write requests for inserting and updating data.
I got my process.php file, first I call the global $ wpdb , but my insert and update requests do not work, so I found a solution from the network that requires config.php in the process file.
require_once( str_replace('//', '/', dirname(__FILE__) . '/') . '../../../wp-config.php');
Then global $ wpdb works fine. But the wordpress repository says it's illegal. I already include the form.php file in the main index.php plugin file, so I also include process.php and comment on the require_once code, but it doesnβt work. I do not know how I can fix this problem.
Here is my form.php code:
<form method="post" action="<?php echo plugin_dir_url(__FILE__); ?>settings_process.php"> <input type="text" name="post_name_slug" id="post_name_slug" value="<?php echo POST_NAME_SLUG ?>" /> <input type="submit" name="save_settings" value="<?php _e("Save Changes","abc") ?>" />
And here is my process.php code:
require_once( str_replace('//', '/', dirname(__FILE__) . '/') . '../../../wp-config.php'); global $wpdb; My insert and update queries
So, is there any other solution for this, please help me.
thanks alot
source share