CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • solved which permission do I have set wrong to get a forbidden with an ajax call
Pages: [1]

Author Topic: solved which permission do I have set wrong to get a forbidden with an ajax call  (Read 1563 times)

bouton

  • Guest
solved which permission do I have set wrong to get a forbidden with an ajax call
November 18, 2011, 08:44:19 am
I have an ajax call (not external) which retrieves data from civicrm/ajax if I am logged on but does not if I am an anonymous user. I've set anon drupal users  to view everything but it still doesn't seem to work - any suggestions?
Thanks
« Last Edit: November 21, 2011, 03:35:23 am by bouton »

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: which permission do I have set wrong to get a forbidden with an ajax call
November 18, 2011, 09:27:45 am
Hi,

You have to give them access to civicrm. Based on the query you want to do, you might have to give them more rights.

This is probably way too much rights and power for anonymous users that you feel comfortable with.

As of the next version of civi, you'll have a hook to be able to grant different rights to some specific api actions including for anonymous, right now, you need to give at least "access to civicrm".

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

bouton

  • Guest
Re: which permission do I have set wrong to get a forbidden with an ajax call
November 21, 2011, 01:17:01 am
Really? Wow - that won't do at all. Anonymous access to civicrm. hehehehehehehe

Any suggestions on how to otherwise present them with the data I want?
Will I have to do my own direct sql call?

Thanks for the quick reply.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: which permission do I have set wrong to get a forbidden with an ajax call
November 21, 2011, 02:54:41 am
Quote from: bouton on November 21, 2011, 01:17:01 am
Any suggestions on how to otherwise present them with the data I want?
Will I have to do my own direct sql call?

Instead of SQL, you could write a small Drupal module which calls the API in PHP and returns the data. Then your Ajax can call that function via the URL you will create for it. Then that URL (in hook_menu) can be restricted by whatever permissions you choose.
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

bouton

  • Guest
Re: which permission do I have set wrong to get a forbidden with an ajax call
November 21, 2011, 03:35:03 am
Thanks - that is exactly what I did after I re-read the documentation and saw that php doesn't have the same permission issues.
Worked out perfect - again - thanks for quick replies.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: solved which permission do I have set wrong to get a forbidden with an ajax call
November 21, 2011, 09:04:40 am
Dear reader from the future,

This solution is nice and works and will still be working.

As of 4.1 (or 4.0.7?) there is another option (I should blog about it soon)

- write a custom api (in your api/v3/Whatever.php) ie. a function civicrm_api3_whatever_do ()
- and use the permission hook to grant anonymous the right on api.whatever.do

Probably about the same amount of work as bouton did, but it would allow you to use your function from smarty, REST...


X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • solved which permission do I have set wrong to get a forbidden with an ajax call

This forum was archived on 2017-11-26.