Why can’t I use add_filter(‘page_template’) more than once in my plugin?
What can I do to solve the problem?
add_filter('page_template', 'my_plugin_login_page');
function my_plugin_login_page($login_template)
{
$plugin_option = get_option('login_settings');
$login_page = get_post_field('post_name', $plugin_option ['login-page']) ? get_post_field('post_name', $plugin_option ['login-page']) : 'login';
if (is_page($login_page)) {
$login_template = MY_PLUGIN_TEMPLATE . 'login-template.php';
}
return $login_template;
}
This function does not work!
add_filter('page_template', 'my_plugin_logout_page');
function my_plugin_logout_page($logout_template)
{
$plugin_option = get_option('logout_settings');
$logout_page = get_post_field('post_name', $plugin_option ['logout-page']) ? get_post_field('post_name', $plugin_option ['logout-page']) : 'logout';
if (is_page($logout_page)) {
$logout_template = MY_PLUGIN_TEMPLATE . 'logout-template.php';
}
return $logout_template;
}