Support » Plugin: Age Verify » Why not remember my visit to the web?

Viewing 2 replies - 1 through 2 (of 2 total)
  • WordPress Version: 4.0
    Age Verify Version: 0.2.7

    I am having this issue as well. I dug into the code and it appears that the “Remember visitors for” setting is not actually being used at all:

    File: age-verify/includes/functions.php, line 105 to line 119

    function av_get_cookie_duration() {
    
    	$cookie_duration = 720;
    
    	/**
    	 * Filter the cookie duration.
    	 *
    	 * @since 0.1.0
    	 *
    	 * @param int $cookie_duration The cookie duration.
    	 */
    	$cookie_duration = apply_filters( 'av_cookie_duration', $cookie_duration );
    
    	return (int) $cookie_duration;
    }

    There was a little confusion in which functions.php file was being used, so I did some testing and found that it was using the age-verify/includes/functions.php and not the age-verify/functions.php. It appears that age-verify/functions.php is not being used at all on my install.

    I modified this code slightly to use the ‘_av_cookie_duration’ (“Remember visitors for”) option that we are allowed to set in the admin:

    function av_get_cookie_duration() {
    
    	$cookie_duration = (int) get_option( '_av_cookie_duration', 720 );
    
    	/**
    	 * Filter the cookie duration.
    	 *
    	 * @since 0.1.0
    	 *
    	 * @param int $cookie_duration The cookie duration.
    	 */
    	$cookie_duration = apply_filters( 'av_cookie_duration', $cookie_duration );
    
    	return (int) $cookie_duration;
    }

    Author — could you please address this bug and push an update?

    Also, while on the topic of the “Remember me” feature, could you please add a way to automatically remember the visitor and hide the checkbox? I do not like modifying a plugin’s code unless it is absolutely necessary (like above), mainly because it gets overwritten every time I update.

    I forgot to mention…awesome plugin! I appreciate you taking the time to write it and share with others.

    Kindest regards,
    Dale Higgs

    I went ahead added the auto-remembering feature myself for now. I added this to my theme’s functions.php file:

    /**
     * Make Age Verify automatically remember the visitor
     */
    add_filter( 'av_verify_form', 'av_custom_auto_remember_on' );
    
    function av_custom_auto_remember_on( $form ) {
    	return str_replace(
    		'<label for="av_verify_remember"><input type="checkbox" name="av_verify_remember" id="av_verify_remember" value="1" /> Remember me</label>',
    		'<input type="hidden" name="av_verify_remember" value="1" />',
    		$form
    	);
    }

    Please note that this could break if the language is changed, or if the plugin is updated and changes the HTML of this field.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Why not remember my visit to the web?’ is closed to new replies.