Announcement

Collapse
No announcement yet.

Google Adsense Optional For Paying Users.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Google Adsense Optional For Paying Users.

    Hi. I have Google Adsense on my site. I have created a Single-Selection Radio Button profile option called "Remove Google Adsense" (id 27). With the options "Keep Adsense" and "Remove Adsense" (in that order).

    I want an if statement around the Adsense code that does the following:

    If users is group id is 5 and profile field id27 is "Remove Adsense" skip the adsense code.

    Alternatively.

    If user is not group id 5 show adsense, unless group id 5 user field id27 is "Kepp Adsense".

    Any help is gratly appreciated. Thanks.
    Mike Warner
    MIGWeb - a Vauxhall Site for Enthusiasts of all Vauxhalls

  • #2
    Another though - to make it easier, I could add the code twice. Firstly:

    If user is not group ID=5, show adsense.


    then after this.

    If user is ID=5 and field27="Show adsense", show adsense.

    Cheers.
    Mike Warner
    MIGWeb - a Vauxhall Site for Enthusiasts of all Vauxhalls

    Comment


    • #3
      Did you get any responses on this? I think this is a great example of conditionals and I would like to learn more based on a useful example like this. Or is this a vB.org question?
      sigpic

      Comment


      • #4
        I have the same question on vBulletin.org - also unanswered. I've done loads of search but have found no exapmles of conditionals based on user profile data.

        All I need to know now really is how to do:

        <if user group is 5 and custom profile field 27 is "Show Adsense">
        <adsense code>
        </if>
        Mike Warner
        MIGWeb - a Vauxhall Site for Enthusiasts of all Vauxhalls

        Comment


        • #5
          I am not sure what the profile field section would be, though to limit it to certain usergroups:

          PHP Code:
          <if condition="is_member_of($bbuserinfo,6)">
          &
          nbsp;
          <else />
          Adsense Code
          </if> 
          You can also simply limit it to an IF statement, such as:

          PHP Code:
          <if condition="is_member_of($bbuserinfo,6)">
          adsense code
          </if> 
          If you want to limit it to 2 groups, you can use OR in the condition, like below:

          PHP Code:
          <if condition="is_member_of($bbuserinfo,6) OR is_member_of($bbuserinfo,5)">
          show code
          </if> 

          Hope that helps.

          Comment


          • #6
            Mike,

            Can you provide the code on how to make the radio button?

            Comment


            • #7
              This is an option in the CPanel.
              Mike Warner
              MIGWeb - a Vauxhall Site for Enthusiasts of all Vauxhalls

              Comment


              • #8
                I use a box in the profile that allows members to displays ads even though they have a subscription (dont ask me why anyone would want to see ads having paid the fee). mine is a bit more complicated, since depending on which group you are in, you are exempt from ads, but here is my script, used to be in phpinclude, now it's a plugin:

                PHP Code:
                if (((in_array($bbuserinfo['usergroupid'],array(5,6))) || (is_member_of($bbuserinfo,14))) && ($bbuserinfo['field6'] != "Yes")) {
                    
                $google_ads_top '';
                    
                $google_ads_post '';
                } else {
                    if ((
                in_array(THIS_SCRIPT,array("index","forumdisplay","showthread","showpost"))) && (!in_array($forumid,array(8,24,28,29,1)))) {
                        
                $google_ads_top 'Your ad';
                        if (
                in_array($bbuserinfo['usergroupid'],array(1,3,4))) {
                            
                $google_ads_post 'Your Google ad';
                        } else {
                            
                $google_ads_post '';
                        } 
                // end if
                    
                } else {
                        
                $google_ads_top 'Non-Google ad';
                        
                $google_ads_post '';
                    } 
                // end if
                // end if 
                Now, you will need to edit this to your needs because, for instance, unregistered users see 2 ads, while everyone else (except people who dont see ads) see one.
                HFT Online - Professional computer help ... with a personal touch

                Comment


                • #9
                  HTML Code:
                  <if condition="!is_member_of($bbuserinfo,5) || $bbuserinfo['field27']">
                  <!-- Your Adsense Code -->
                  </if>  
                  Assuming it's a checkbox, that should work.

                  Comment


                  • #10
                    Actually, see my thread here about some corrections to the variable in the plugin system.
                    HFT Online - Professional computer help ... with a personal touch

                    Comment


                    • #11
                      Originally posted by TCM
                      HTML Code:
                      <if condition="!is_member_of($bbuserinfo,5) || $bbuserinfo['field27']">
                      <!-- Your Adsense Code -->
                      </if>  
                      Assuming it's a checkbox, that should work.
                      Thanks - I'll change it to a check box and I'll let you know how I got on.
                      Mike Warner
                      MIGWeb - a Vauxhall Site for Enthusiasts of all Vauxhalls

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...
                      X