I was using a pretty standard login redirect script in my theme functions, however have learned that it is causing a bug with an integral plugin for my website. In short, within the plugin's front end system user's can register for accounts in a lightbox modal. With my general redirect turned on the modal isn't able to complete registration.
So, what I am trying to do is run my login redirect on all pages EXCEPT one page which I can identify by the slug. This page is auto generated by the plugin so I don't have an ID or anything.
Here is my existing login redirect. It's pretty simple.
add_action('wp_login','auto_redirect_after_login');
function auto_redirect_after_login(){
wp_redirect(home_url());
exit();
}
My hurdle is this user registration can occur on an infinite number of pages however they are all "children" of the plugin. Meaning all of them have the same url structure.
All pages that I need to NOT have the redirect work on will be .com/courses/*
Any ideas?
********** UPDATE **********
Here is where I am now, but it doesn't work.
add_action('wp_footer', 'detect_page_for_redirect');
function detect_page_for_redirect(){
if( !is_singular('course')) {
add_action('wp_login','auto_redirect_after_login');
}
}
function auto_redirect_after_login(){
wp_redirect(home_url());
exit();
}
is_singular
condition will not do anything because it is after the form submission and will no longer be detected as being on a course page.