Defender lockout screen customization hooks

Are there any hooks/templates that would allow full customization of lockout screens (Login/IP/404 bans)? There are options to customize messages via Defender's settings page but the goal is to create fully customized "security pages", preferably via a custom mu plugin.

  • Katya Tsihotska

    Hi Micha

    Hope you're having a wonderful day!

    Since this is dealing with more advanced coding topics, I'm going to ping our SLS Team (code experts) to get their valuable feedback on this question. One of our SLS members will reply back here as soon as more information is available.

    Please keep in mind that our SLS Team deals with more complicated issues, thus it may take a little longer for them to reply here. Thank you for your patience while we look into this further.

    Meantime, you can find template of the lockout page at the /wp-content/plugins/wp-defender/app/module/ip-lockout/view/locked.php
    However, any changes that you'll make there will be overridden with the plugin update, but you can use it as the workaround while we are waiting for the response of our SLS team.

    Kind regards,
    Katya

  • Ivan

    Hi Micha !

    You can try to add this function to {wordpress_folder}/wp-content/plugins/wp-defender/app/controller.php file via FTP

    /**
    	 * <a title=param href=/profile/param>param</a> $viewFile
    	 * <a title=param href=/profile/param>param</a> array $params
    	 * <a title=param href=/profile/param>param</a> bool $echo
    	 *
    	 * @return bool|string
    	 */
    	public function renderPartial( $viewFile, $params = array(), $echo = true ) {
    		ob_start();
    		$content =  parent::renderPartial( $viewFile, $params, $echo );
    		ob_end_clean();
    
    		$content = apply_filters( 'wd_render_partial', $content, $viewFile, $params );
    		if ( $echo ) {
    			echo $content;
    		}
    
    		return $content;
    	}

    Please, add this code before the last curly brace in this file.
    I also will provide this code to the next version of the plugin.

    Then, you can use it via MU plugin.

    <?php
    function wpmu_defender_change_locked_template( $content, $viewFile, $params ) {
    	if ( 'locked' === $viewFile ) {
    		ob_start();
    		include_once get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'defender' . DIRECTORY_SEPARATOR . 'locked.php';
    		$content = ob_get_clean();
    	}
    	return $content;
    }
    add_filter( 'wd_render_partial', 'wpmu_defender_change_locked_template', 10, 3 );

    And add a new locked.php file to defender folder of your current child theme.
    Note: in the new locked.php file you should use $params['message'] instead of $message variable

    Best.
    Ivan.