Trigger AgeGate with JavaScript
-
Hello ??
I wanted to show agegate only to users who set their buddypress profile to be mature content.
I have already setup some code but I am not able to trigger agegate with javascript and also need a “if agegate has been approved” check.
function mature_content_restriction() { function restrict_content(){ add_filter( 'age_gate_restricted', true, 0); } $user_id = bp_displayed_user_id(); $user_profile_mature = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( 90, $user_id ) ); echo ('<input type="hidden" id="mature-content-filter" value="' . $user_profile_mature . '" />' ); ?> <script> var matureCheck = document.getElementById("mature-content-filter").value; if(matureCheck === "1"){ console.log("Ist Mature User"); <?php restrict_content(); ?> var style = "<style id='mature-content-blur' type='text/css'>.yz-header-cover,.avatar{filter:blur(15px);}</style>"; jQuery('head').append(style); if(AgeGate = 'passed'){ jQuery('#mature-content-blur').remove; } } var slug = window.location.pathname; if('/wordpress/profiles/' === slug){ console.log("Ist Profiles Mature"); <?php restrict_content(); ?> } </script> <?php } add_action( 'wp_head', 'mature_content_restriction');
Would be great if you could help me here, since I can’t figure out how to do this.
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Trigger AgeGate with JavaScript’ is closed to new replies.