0

I'm developing my first plugin. It creates directories and save the path, level (if it is a subdirectory of other created directory) and name in a custom table, created at the activation.

The plugin has an option page where users can manager the files in each directory or create more directories and upload more files. In this option page I had to create a form with action atribute as <?php echo EASYDM_PLUGIN_URL; ?>generate-dir.php.

The problem is when I try to use the constants like WP_CONTENT_URL, ABSPATH wordpress tells me they are undefined constants... just in this page of action atribute. Why?

I tried add_action( 'admin_init', 'easydm_register_settings' ); with register_setting( 'pluginPage', 'easydm_settings' ); and so on, but when I click in submit button the page redirects me to the file.php in action but as wp-admin/file.php. So, neither the first nor the second way are working for me. How can I do that?

  • i think you need to define ABSPATH and other constants within the plugin code like: ` define( 'ABSPATH', dirname(FILE) . '/' );` – MikeiLL Mar 12 '16 at 5:23
  • 1
    kinda pointless to ask "why my code is not working" without showing it. No need to dump all your code, just relevant parts – Mark Kaplun Mar 12 '16 at 5:26
  • If your code is overly long or spread across multiple files, you can use pastebin.com to create snippets that you can link to in your question. – Adam Mar 12 '16 at 6:50
0

Post the form instead back to the same admin page you are coming from instead (basically using form action=''), then detect the form posting on that page (eg. if (isset($_POST['createdir'])), and then include the file that will actually process the request (eg. include(EASYDM_PLUGIN_URL.'generate-dir.php');)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.