WordPress.org

Forums

Age Verify
Why not remember my visit to the web? (3 posts)

  1. paco.bastida
    Member
    Posted 8 months ago #

    Why not remember my visit to the web? When I return to the home always appears.

    Attached image

    Thank you very much
    https://wordpress.org/plugins/age-verify/

  2. dale3h
    Member
    Posted 6 months ago #

    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

  3. dale3h
    Member
    Posted 6 months ago #

    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.

Reply

You must log in to post.

About this Plugin

  • Age Verify
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.