• I have a function that redirects logged in users to a certain page when they try to visit the home page. This function works exactly as it should but in WordPress 4.9.x the code validation fails if there is any script to redirect users. If I remove the function then the error goes away and the file saves fine. The function is below:

    function homepage_template_redirect() {
    	if( is_front_page() && is_user_logged_in() ) {
    		wp_redirect( get_permalink( get_page_by_title( 'My Tickets' )));
    		exit();
    	}
    }
    add_action( 'template_redirect', 'homepage_template_redirect' );
Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    If I paste that into the editor, it works for me. Do you see a little red button? If so, hover or click to see the error text.

    Thread Starter mhennessie

    (@mhennessie)

    Thanks for checking it out.

    There is no red button. The error doesn’t appear until I try to save the file. Instead of saying “File edited successfully.” it says “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.” If I remove that snippet, the save is successful.

    Thread Starter mhennessie

    (@mhennessie)

    Note: the error also appears when changing the theme to Twenty Seventeen and adding the code to the functions.php.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    That’s a different problem. Please install the health check plugin and report back its findings: https://wordpress.org/plugins/health-check/

    Thread Starter mhennessie

    (@mhennessie)

    That is the problem I was trying to describe using the title. I installed the health check plugin and everything has a green check except for the mysql version which has a yellow dash because I am not running v5.6.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    If you disable all plugins via the Health Check plugin?

    Thread Starter mhennessie

    (@mhennessie)

    I still get the same message – “Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.”

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Unable to check for fatal errors – homepage redirect function’ is closed to new replies.