I am sorry to bring this up here but in the instructions it says the profile field MUST be set on private. Can it be put on hidden if i do not want to share revenue?

It seems pretty mean to have an adsense field on user profiles and not share revenue.

Please let me know. Thanks.

CommentFileSizeAuthor
#13 README_appended.txt3.1 KBzoon_unit

Comments

kbahey’s picture

Status: Active » Closed (fixed)

The help in admin/settings/adsense clearly says :

Note that the new profile field must be setup as: "Private field, content only available to privileged users". All other values are either insecure or will not work, so do not use any of them.

mstef’s picture

OK, i just had trouble understand why hidden could be less secure than private

kalashari’s picture

Version: 4.7.x-1.0 » 5.x-1.0

Is it somehow possible for regular users NOT to have a field "Google AdSense client ID" when they go to edit their profile? It doesn't make sense for regular users to have this field if I am not using "revenue sharing".

darren oh’s picture

Status: Closed (fixed) » Active

Yes, it's possible. We could use hook_form_alter() to hide the field based on a user's access permissions.

drewish’s picture

i think the whole revenue sharing is a nice feature but it shouldn't be the default. you should be able to use this module without going to the hassle of adding the profile field if you're not going to use revenue sharing.

BobLouis’s picture

I have just installed the module, and I agree with Drewish, Kalashari...
So, has a solution been found for regular users NOT to have a field "Google AdSense client ID" displayed when they edit their profile?

Petra’s picture

I am also interested in this solution. I am still untrained in drupal - I read the solution with more hook_form_alter () in such a way, as if I would have to change thereby profile modules.
In addition it would be useful, if thereby not only individual fields, but a profile Category for user of roles could be activated/deactivated. (I have the field "Google AdSense client ID" assigned to a category, in which there is no other field. And it would be just as unpleasant, if each user gets the category, but therein no field is indicated.)
And a solution, which is compatible to http://drupal.org/node/144599 (Different sharing percentage basing on user role) would be great.

BlakeLucchesi’s picture

Priority: Normal » Critical
Status: Active » Closed (fixed)

Hackish as it may be, it works...

In your user.module file you will have to set a conditional statement around the menu declaration (somewhere around line 818)

function user_menu($may_cache){
...
...  // All the way to the bottom of the function
...
 if (arg(2) == 'edit') {
  if (($categories = _user_categories($account)) && (count($categories) > 1)) {
   foreach ($categories as $key => $category) {
    if($category['name'] != 'adsense'){  //  ADD THIS LINE  (Remember you need to add a closing } to after the $items block directly below
    	$items[] = array(
          'path' => 'user/'. arg(1) .'/edit/'. $category['name'],
          'title' => $category['title'],
          'type' => $category['name'] == 'account' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
          'weight' => $category['weight'],
          'access' => ($admin_access || $user->uid == arg(1)));
	}
      }
    }
  }
}

Now when you define your new profile field create it in its own profile category called 'adsense' if you name it something else.. it won't work. Hope this helps someone else out, it's really not a great fix because updating your site will cause it to be overwritten, but for those desperate to get it to work, this will have to do. There really isn't any other work around unless the adsense module actually creates its own menu hook and tracks user submitted codes in its own table...

regards,
Blake

BlakeLucchesi’s picture

oops. I forgot to add a condition to the if statement that checks to see if the user is the admin (user id = 1).

you can do this by substituting this line of code for the line i mentioned in the above post

if($category['name'] != 'adsense' || ($category['name'] == 'adsense' && $user->uid == 1)){
drewish’s picture

Status: Closed (fixed) » Active

blucches, you offered up a hack which is nice but it's not really the conclusive solution that would usually warrant closing an issue.

zoon_unit’s picture

Here's a workaround for this issue:

1) Set up the profile field as described in the help file ("Private field, content only available to privileged users") and enter your account number. Press save. This will store the record in the profile_values table.

2) Go back and set the field to "hidden profile field, only accessible by administrators, modules and themes" This option stores the value in a completely different table, which is why it won't work normally for Google Adsense, which is designed to retrieve the value from the profile_values table. The key HACK here is by initially setting the field up correctly and saving, you have stored the value in the proper location. When you go back and change the field type, it DOES NOT delete the original value in the profile_values table, so the Adsense module will continue to find and load the ID properly. However, the field will now be invisible to other users.

NOTE: Just keep in mind that if you need to change the ID value later, you will first need to:

1) Set the field option back to "Private field, content only available to privileged users"
2) Put in the new value and save
3) Then set the field option to "hidden profile field, only accessible by administrators, modules and themes"

You can check to make sure the Adsense module is picking up the proper value by viewing the source of a page with the ads and checking the javascript code. You should see the value of your account there.

darren oh’s picture

Component: User interface » Documentation
Priority: Critical » Minor

If you will add this to README.txt, I'll get it committed.

zoon_unit’s picture

StatusFileSize
new3.1 KB

Here is the new readme.txt file, renamed readme_appended.txt.

Feel free to use or change at your discretion.

darren oh’s picture

Status: Active » Needs review
darren oh’s picture

Version: 5.x-1.0 » 5.x-1.x-dev
Status: Needs review » Fixed

Added in CVS commit 72117.

kbahey’s picture

Version: 5.x-1.x-dev » 5.x-1.6
Anonymous’s picture

Status: Fixed » Closed (fixed)
vrc3’s picture

I have to say, this is a very annoying "feature". Enough to make me not want to use this module. :(