Non WP Rewrite Rule to Admin Screen using plugin
-
Howdy all, thanks in advance for your help. I am creating a plugin that uses the administration screen extensively (adapting a rather complex, MVC program to WordPress for Creative Collaboration). I want do use simple urls so that when a user goes to /studio/whatever the url is rewritten to the correct admin screen.
There is probably a better way to do this. This is the end result that I’m looking for:
www.example.com/studio/whatever/whatever2
gets rewritten to:
www.example.com/wordpress/wp-admin/admin.php?page=_cs&uri=whatever/whatever2
I’ve actually gotten this to work with the following code:
add_action('generate_rewrite_rules', 'cs_rewrite_rules'); function cs_rewrite_rules() { global $wp_rewrite; $new_non_wp_rules = array( 'studio/(.*)' => 'wordpress/wp-admin/admin.php?page=_cs&uri=$1', ); $wp_rewrite->non_wp_rules += $new_non_wp_rules; }
I’ve used several analyzers and the URL is being rewritten fine. However, when I run it in wordpress, I am redirected to a login screen. The loop is infinite. I never get to the admin panel. However, if I go there directly, everything works wonderfully.
There is probably another way to do this. I considered using template_redirect or template_include as discussed in another thread, but neither of those give me the admin credentials or boot process.
I am stuck and would love some help.
Thank you,
Michael.
- The topic ‘Non WP Rewrite Rule to Admin Screen using plugin’ is closed to new replies.