• I wonder if anyone has any bright ideas on how this can be achieved.

    I need to restrict access to users until they simply click a checkbox at the bottom of a disclaimer which has a name field but nothing else (but also records their IP).

    So in theory what I am looking for is to restrict content without the user needing to register or login.

    So for example with a cookie(?) confirm they have accepted the disclaimer and when the cookie expires, then they would just be presented with the disclaimer again and the site would again be restricted.

    Once more for clarification:
    User comes to site, disclaimer appears, user needs to put in name and click check box and submit. Once submitted, name, confirmation and IP address are saved to the database. User now has access to the website.

    I have searched a lot by mostly find user registration plugins. Has anyone seen anything like this?

Viewing 1 replies (of 1 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I’ve done this.

    I set up a form using the plugin Formdidable and hooked the form’s submit. When the form is submitted, I set a cookie.

    
    /* hook the form action */
    add_action( 'frm_after_create_entry', 'resource_registered', 30, 2 );
    function resource_registered( $entry_id, $form_id ) {
    	if ( $form_id == 18 ) { //replace 5 with the id of the form
    		setcookie( 'sbac_resource_registered', 'registered', time() + 31556926, '/' );
    	}
    }
    
    /* reject access if cookioe not set */
    
    function resource_register_check() {
    	if ( ! isset( $_COOKIE['sbac_resource_registered'] ) ) {
    		wp_redirect( '/please-register-to-access-resources/' );
    		exit();
    	}
    }

    The function resource_register-check() is added to the the page templates for pages that should be restricted.

Viewing 1 replies (of 1 total)
  • The topic ‘Content Restriction without registering.’ is closed to new replies.