I am working in WordPress plugin. I create a custom form where user add values and then click on submit button. When user click on submit button its redirect to custom process file, where i write queries for inserting and updating data.
I my process.php file, first i call global $wpdb, but my insert and update queries not working so i found a solution from net to require config.php file in my process file.
require_once( str_replace('//', '/', dirname(__FILE__) . '/') . '../../../wp-config.php');
Then global $wpdb work perfectly. But the wordpress repository says that its illegal. I already include my form.php file in plugin main file index.php, so i also include process.php and comment the require_once code but its not working. I don't know how can i fixed this issue.
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