Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'bp_template_redirect', function() {
- if ( ! is_user_logged_in() ) {
- return;
- }
- $user_id = bp_loggedin_user_id();
- $redirect_url = bp_core_get_user_domain( $user_id ) . bp_get_profile_slug();
- $memberDob = xprofile_get_field_data( 'DOB', $user_id );
- $diff = (date( 'Y' ) - date( 'Y', strtotime( $memberDob ) ) );
- if( $diff < 18 ) {
- if( is_buddypress() && ! bp_is_user_profile() ){
- bp_core_redirect( $redirect_url . '/edit/' );
- }
- }
- } );
- add_action( 'wp_footer', 'wbcom_age_verificarion_popup' );
- function wbcom_age_verificarion_popup() {
- if ( ! is_user_logged_in() ) {
- return;
- }
- if( is_buddypress() && bp_is_user_profile() ){
- $member_id = bp_loggedin_user_id();
- $memberDob = xprofile_get_field_data( 'DOB', $member_id );
- $diff = (date( 'Y' ) - date( 'Y', strtotime( $memberDob ) ) );
- if( $diff < 18 ) {
- ?>
- <div id="age-verification" onclick="ageVerificationHide()" >
- <div class="age-verification-main">
- <span class="age-title"><?php _e( 'Are you 18 or older?', 'reign' ); ?></span>
- <span class="age-main-text"><?php _e( 'You must be of legal age to view our website. Due to legal requirements you must verify your age.', 'reign' ); ?></span>
- </div>
- </div>
- <script type="text/javascript">
- function ageVerificationHide() {
- var ageVerificationModel = document.getElementById('age-verification');
- ageVerificationModel.style.display = 'none';
- }
- function ageVerificationShow() {
- var ageVerificationModel = document.getElementById('age-verification');
- ageVerificationModel.style.display = 'block';
- }
- document.addEventListener("DOMContentLoaded", function(event) {
- ageVerificationShow();
- });
- </script>
- <?php
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement