Support » Plugin: Age Gate » Trigger AgeGate with JavaScript

  • nushara


    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 . '" />' );
            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>";
                if(AgeGate = 'passed'){
            var slug = window.location.pathname;
            if('/wordpress/profiles/' === slug){
                console.log("Ist Profiles Mature");
                <?php restrict_content(); ?>
    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 1 replies (of 1 total)
  • Plugin Author Phil


    Hi @nushara,

    Sorry for the really slow reply here! Do you still need help with this?


Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.