Hello all,
If you are familiar with the AdSense module, you'll know that when you set it up you must create a single-line text field so you can enter your personal AdSense ID (not forgetting to NOT select "Hidden profile field", otherwise AdSense module won't take your ID). This creates an entire section at user/*/edit/adsense-profile-category-name to do so. Fine and dandy, I have entered my AdSense ID and everything is up and running fine.
Here's what's wrong: I don't want to use revenue sharing. I don't want users to have the AdSense section in thier account menu at all. So I go to administer > profiles > my custom AdSense profile and check "Hidden profile field, only accessible by administrators, modules and themes". To my disappointment, this only removes the single-line text box from the AdSense section in the user accounts, not the entire section. I want the entire section gone. I believe it will cause support headaches with users wanting to use it or hack it.
How can I modify the AdSense module code to remove the section for all users except me?
or
Is there a way to input my personal AdSense ID somewhere else so I don't have to use the profile field at all?
Thanks in advance...
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | adsense.module_1.patch | 4.27 KB | denney |
| #10 | adsense_4.patch | 4.13 KB | matt@antinomia |
| #9 | adsense_3.patch | 2.86 KB | matt@antinomia |
Comments
Comment #1
kbahey commentedIn the current 4.7 version, there is no way to NOT use the profile field.
However, you can work around this by adding a description to the field that informs users to ignore this field completely.
I think a better way to handle this in a future version is to restrict the entry of the field to certain roles, but the profile module does not allow that at present, so it has to be some other custom code.
Comment #2
introfini commentedYou can add it to a category that already exists and make the field hidden. This way you get rid off it completely.
introfini
Comment #3
kbahey commentedIf you mean "Hidden profile field, only accessible by administrators, modules and themes", then it WILL NOT WORK.
Comment #4
introfini commentedIt works if you make it part of an existing profile category. If you don’t have one created you can add the space character as the category name.
introfini
Comment #5
kbahey commentedI am not understanding what you say.
You said:
Forget the category for now. I was commenting on the part in bold, when I said that "Hidden profile field, only accessible by administrators, modules and themes" will not work.
Are you saying that setting it as "hidden profile field" will work with Adsense?
It will not, the reason is that when you set a field to hidden, the data is stored in the users table not the profile_values table.
Moreover, if you set the field to hidden, and then later change it to private, the data will not be automatically moved from the users table to the profile_values table.
Only when you go and edit your user account and save the field ones more would it go to the profile_values table.
Comment #6
introfini commentedIt works if you first create the field as stated in the Help and later change it to "Hidden profile field, only accessible by administrators, modules and themes.". I’ve tested it in a clean install.
introfini
Comment #7
kbahey commentedYes, that works, and the other way around too.
Note that this is most probably a bug in the profile module, and not a feature. If you change the type, it should change it for all users on the spot, not when you edit each user subsequently.
I would not rely on this behavior to remain the same in the future.
Comment #8
jrstmartin commentedThanks for all the input you guys :-). I changed the category name to a space and it works.
Comment #9
matt@antinomia commentedRegarding this issue, I agree with jrstmartin that revenue sharing should be an optional feature and should require enabling a profile field and then hiding it in order to make this module work properly. I propose putting the AdSense ID field back on the setting page. If the AdSense ID is entered in this field, the revenue sharing feature is disabled.
Patch attached.
Comment #10
matt@antinomia commentedOn second thought, this could probably be done a little more logically. It seems to me that the Google Adsense Client ID Profile Field should simply fall under the 'Revenue Sharing options' settings area, and be required when 'Revenue Sharing' is enabled...
Comment #11
denney commentedSubscribing to this....
I to would like to have just an Adsense ID field in the settings page without having to create a profile field. I'm the only user on the site that needs the Adsense ID.
BTW, I'm running Drupal 5.
Comment #12
jrstmartin commentedI know what I am about to say is anti-AdSenseModule but, depending on your situation, just use blocks for your AdSense ads. Using blocks with revenue-sharing works too - just create a block for whomever is authorized and insert their AdSense code into that block. Then if you use clean URLs/pathauto module correctly, you can set up URL rules for the individual AdSense blocks.
I guess on a large scale this wouldn't be ideal but, instead of messing with the module and the profile field just go back to the basics. I love the AdSense module though :).
You can see what I'm doing with AdSense & revenue-sharing on my site and partake if you'd like.
Comment #13
kbahey commented@jsmartin, whatever floats your boat. Adsense module (or any module) can never cover 100% of the cases. If some find it useful, then well and good. If it is not useful, then you don't have use it.
On the other hand, I helped several startup sites with doing revenue sharing on User Generated Content, and they are doing fine. My sites have this module enabled and they are doing fine.
So, whatever ...
Back to the issue at hand: there is a possible way to hide the Google Adsense field from certain roles when they edit their profile.
We can do a form_alter() on the appropriate profile field, and unset the form items for Adsense.
If someone makes a patch and tests it, I will include it.
Comment #14
snsace commentedI changed the profile category to a "space" and it got rid of the profile tab in user accounts. Of course, it got rid of the profile access for my UID 1 as well.
How can I can view/access my adsense account?
Comment #15
denney commentedHere is a patch for Drupal 5.1 made against Adsense 5.x-1.3.
Comment #16
spooky69 commentedjust posting to keep an eye on this
Comment #17
matt@antinomia commentedKhalid, is there any reason we can't just eliminate the profile.module requirement for sites that aren't using it? For a single-publisher site, there is no reason (IMNSHO) one should be required to enable the profile module just to use the wonderful functionality included in this module...
Comment #18
kbahey commentedMatt
I have a few sites that have no revenue sharing, and they are setup with profile fields with no issues at all.
I will consider working and tested patches that preserve revenue sharing as it is, but simplify the no-revenue sharing mode. They must be fully regression tested to make sure that nothing breaks by more than one person.
Comment #19
marceloverdijk commentedWhat's the status on this? I aldo don't want to use the profile module.
Alternative for me is just to use php blocks.... but I would rather user a module.
Comment #20
WeRockYourWeb.com commentedHmm, interesting. I've been using "hidden" all along on all my sites and don't seem to be having issues (when I check the source code the adsense ID is filled in for the ad). I suppose you could blend out the field with CSS after filling it in, but users will still see the "adsense" text.
/* hide adsense field */
#edit-profile-google-adsense-client-id { display: none }
Cheers,
Alex
----------
Contract Web Development, Inc.
Comment #21
kbahey commentedI have been thinking of this more lately, and I have a possible solution.
This goes in conjunction with #211822 where the revenue sharing is selectable via a module.
We break out the profile stuff in a separate module, called adsense_revenue_basic.module.
If this module is not enabled, then a simple text box in settings is used by the site owner to fill in his ID: plain and simple. No fuss no mess.
Those who need revenue sharing now have several options:
1. Enable the adsense_revenue_basic.module, together with the user profile module, and it would do what happens today.
2. Use the new hook outlined in #211822 to write a new module that gets the Adsense ID whichever way they want.
How is that for a plan? Anyone willing to help make it a reality?
Comment #22
Petra commentedSounds good, and I will help you.
I have 3 sites over which I can test (one with revenue sharing)
I know php (have own scripts), but so far I know very little about drupal.
What should I do?
Comment #23
kbahey commentedThanks Petra
When I have time, I will implement these changes, unless someone does it before I do.
Then you can help with testing the changes.
Keep watching your inbox for updates to this issue.
Comment #24
kbahey commentedThis is now implemented. Adsense does not depend on the profile module anymore, unless you want to use revenue sharing.
For sites that don't want revenue sharing, a new module called adsense_basic is included and provides a simple text field that you put your Adsense Client ID in, and that is it.
The new code should be in the 5.x-2.x release by tomorrow.
Comment #25
Petra commentedI tested adsense_basic - works fine. Also tested revenue-sharing - but only local, cause I wait for your answer here: http://drupal.org/node/220534
I thought that revenue-sharing can't work with cache enabled - so there is no change to the previous version of the module.
Comment #26
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.