template_redirect hooks redirect wrong URL

The code adds the functions like this: add_action (‘template_redirect’, array( ‘loginForm’, ‘set_submit_login_func’)); Which tells PHP to do this when template_redirect happens: loginForm::set_submit_login_func(); But we can see set_submit_login_func in the questions code and it is clear that it is not a static function: public function set_submit_login_func(){ What you want is a dynamic callable, e.g. class MyClass … Read more

Redirect Pending Review Status Preview page url to custom url

function mmk_pending_review_redirect(){ $user = wp_get_current_user(); if(get_post_status ( get_the_id() ) != ‘publish’) if (is_user_logged_in() && !in_array( ‘administrator’, (array) $user->roles ) && !is_author() ) { wp_redirect( “https://example.com/under-approval”); exit; }else{ wp_redirect( “https://example.com/under-approval”) ); exit; } } } add_action(‘template_redirect’, ‘mmk_pending_review_redirect’); explanation: redirect non-admin users to custom URL if they are not author of the current post where status is … Read more

How to access my wordpress application using two URLs?

So this had been a constant issue for me but finally i got this working, thanks to this blog post. http://www.velvetblues.com/web-development-blog/turn-off-wordpress-homepage-url-redirection/ It seems like adding this in the functions.php file for the enabled theme works. Pasting here for anyone who may be facing a similar issue. remove_filter(‘template_redirect’,’redirect_canonical’); I restarted the httpd and the php-fpm service, … Read more

Redirect when not logged and parametr in link

This should work for what you’re looking to achieve; add_action( ‘template_redirect’, ‘redirect_to_specific_page’ ); function redirect_to_specific_page() { if ( ! is_user_logged_in() && ! is_page(‘one_time_login’) ) { wp_redirect( ‘domain.com/sub’, 301 ); exit; } } This should be added to your theme (or child theme) functions.php file