Answers.Body: <p>I found the problem here. actually there is some issue with CiviCRM Wordpress codebase because its always failing to get wordpress user id.</p>
  
  <p>Below checkDownloadInvoice function using drupal <code>global $user;</code> to get logged in user id for wordpress as well.</p>
  
  <pre><code>CRM_Core_Permission::checkDownloadInvoice
  
  public static function checkDownloadInvoice() {
      global $user;
      $cid = CRM_Core_BAO_UFMatch::getContactId($user-&gt;uid);
      if (CRM_Core_Permission::check('access CiviContribute') ||
        (CRM_Core_Permission::check('view my invoices') &amp;&amp; $_GET['cid'] == $cid)
      ) {
        return TRUE;
      }
      return FALSE;
    }
  </code></pre>
  
  <p>for WordPress It should be changed to </p>
  
  <pre><code>public static function checkDownloadInvoice() {
      $uid = get_current_user_id();//changed for WordPress
      $cid = CRM_Core_BAO_UFMatch::getContactId($uid);//changed for WordPress
      if (CRM_Core_Permission::check('access CiviContribute') ||
        (CRM_Core_Permission::check('view my invoices') &amp;&amp; $_GET['cid'] == $cid)
      ) {
        return TRUE;
      }
      return FALSE;
    }
  </code></pre>
  
  <p>Hope it helps someone in future. :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-18T10:38:33.177Z
Answers.Text: You should put this in the issue queue
Answers.UserDisplayName: Tony Horrocks
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-18T10:39:03.730Z
Answers.LastActivityDate: 2019-01-18T10:23:35.327Z
Answers.LastEditDate: 2019-01-18T10:23:35.327Z
Answers.UserDisplayName: Developer
Body: <p>CMS: Wordpress 4.9.6</p>
  
  <p>CiviCRM: 5.2.1</p>
  
  <p>I'm trying to generate Invoice with the below url, Which is working fine when I login as administrator. but when I login as actual member to download Invoice from WordPress front end with the same url giving me this error</p>
  
  <pre><code>  Sorry, you are not allowed to access this page.
  </code></pre>
  
  <p>( I gave this civi permission </p>
  
  <pre><code>CiviCRM: view my invoices 
  Allow users to view/ download their own invoices
  </code></pre>
  
  <p>to all user roles).
  <a href="https://i.sstatic.net/rhjbg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rhjbg.png" alt="enter image description here"></a></p>
  
  <pre><code>http://devsri.mywebsite.com/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm/contribute/invoice&amp;reset=1&amp;id=48657&amp;cid=35509
  </code></pre>
  
  <p>Its working when I give below(CiviCRM: access CiviCRM backend and API)permission</p>
  
  <pre><code>"CiviCRM: access CiviCRM backend and API" Master control for access to the main CiviCRM backend and API. Give to trusted roles only.
  </code></pre>
  
  <p><a href="https://i.sstatic.net/5p9h3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/5p9h3.png" alt="enter image description here"></a></p>
  
  <p>But I cant give this permission to a member just to download Invoice. In drupal its working with "CiviCRM: view my invoices" permission. I wonder if its a bug in Civi Wordpress??</p>
  
  <p>Did anyone experience this? or Am I missing anything here?</p>
  
  <p>TIA</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-29T11:46:22.620Z
Comments.Text: Probably this link(https://civicrm.stackexchange.com/questions/24616/not-able-to-print-contribution-invoice) might help you. HTH
  Pradeep
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-29T11:52:47.200Z
Comments.Text: Thanks Pradeep, but "View my invoices" permission is enabled for my wordpress. In drupal I tried it with the same permissoin, its working fine on drupal. I feel its a wordpress issue. I tried to check "mywebsite/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Task/Invoice.php" file, its not coming to "public static function getPrintPDF" function. seems wordpress permissions is having some issue in civi.
Comments.UserDisplayName: Developer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-29T12:17:06.073Z
Comments.Text: I think you will provide access civicrm permission.
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-29T12:18:10.850Z
Comments.Text: Or you can try http://devsri.mywebsite.com/default-civipage?page=CiviCRM&q=civicrm/contribute/invoice&reset=1&id=48657&cid=35509
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-29T12:54:24.873Z
Comments.Text: I'm getting this error after change url."The requested URL /default-civipage was not found on this server."
Comments.UserDisplayName: Developer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-29T13:06:37.473Z
Comments.Text: Its working after giving this permission "CiviCRM: access CiviCRM backend and API"
  Master control for access to the main CiviCRM backend and API. Give to trusted roles only. But I cant give this permission to a member. In drupal it is not required
Comments.UserDisplayName: Developer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-29T13:18:53.873Z
Comments.Text: default-civipage is something that is set under http://wpmaster.demo.civicrm.org/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fadmin%2Fsetting%2Fuf&reset=1
Comments.UserDisplayName: Pradeep Nayak
Tags: <wordpress><civicontribute><civicrm-home>
Title: Wordpress Civicrm doesn't seem to generate invoice from other user roles except administrator
ThreadText: # Wordpress Civicrm doesn't seem to generate invoice from other user roles except administrator
  
  (Asked by: username_0 on 2018-06-29)
  
  CMS: Wordpress 4.9.6
  CiviCRM: 5.2.1
  I'm trying to generate Invoice with the below url, Which is working fine when I login as administrator. but when I login as actual member to download Invoice from WordPress front end with the same url giving me this error
    Sorry, you are not allowed to access this page.
  
  ( I gave this civi permission 
  CiviCRM: view my invoices 
  Allow users to view/ download their own invoices
  
  to all user roles).
  
  http://devsri.mywebsite.com/wp-admin/admin.php?page=CiviCRM&q=civicrm/contribute/invoice&reset=1&id=48657&cid=35509
  
  Its working when I give below(CiviCRM: access CiviCRM backend and API)permission
  "CiviCRM: access CiviCRM backend and API" Master control for access to the main CiviCRM backend and API. Give to trusted roles only.
  
  
  But I cant give this permission to a member just to download Invoice. In drupal its working with "CiviCRM: view my invoices" permission. I wonder if its a bug in Civi Wordpress??
  Did anyone experience this? or Am I missing anything here?
  TIA
  
  **Tags:** wordpress, civicontribute, civicrm-home
  
  > **Comments:**
  > **username_1**: Probably this link(https://civicrm.stackexchange.com/questions/24616/not-able-to-print-contribution-invoice) might help you. HTH Pradeep  
  > **username_0**: Thanks Pradeep, but "View my invoices" permission is enabled for my wordpress. In drupal I tried it with the same permissoin, its working fine on drupal. I feel its a wordpress issue. I tried to check "mywebsite/wp-content/plugins/civicrm/civicrm/CRM/Contribute/Form/Task/Invoice.php" file, its not coming to "public static function getPrintPDF" function. seems wordpress permissions is having some issue in civi.  
  > **username_1**: I think you will provide access civicrm permission.  
  > **username_1**: Or you can try http://devsri.mywebsite.com/default-civipage?page=CiviCRM&q=civicrm/contribute/invoice&reset=1&id=48657&cid=35509  
  > **username_0**: I'm getting this error after change url."The requested URL /default-civipage was not found on this server."  
  > **username_0**: Its working after giving this permission "CiviCRM: access CiviCRM backend and API" Master control for access to the main CiviCRM backend and API. Give to trusted roles only. But I cant give this permission to a member. In drupal it is not required  
  > **username_1**: default-civipage is something that is set under http://wpmaster.demo.civicrm.org/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fadmin%2Fsetting%2Fuf&reset=1  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-09-18. Score: 2
  
  I found the problem here. actually there is some issue with CiviCRM Wordpress codebase because its always failing to get wordpress user id.
  Below checkDownloadInvoice function using drupal global $user; to get logged in user id for wordpress as well.
  CRM_Core_Permission::checkDownloadInvoice
  
  public static function checkDownloadInvoice() {
      global $user;
      $cid = CRM_Core_BAO_UFMatch::getContactId($user->uid);
      if (CRM_Core_Permission::check('access CiviContribute') ||
        (CRM_Core_Permission::check('view my invoices') && $_GET['cid'] == $cid)
      ) {
        return TRUE;
      }
      return FALSE;
    }
  
  for WordPress It should be changed to 
  public static function checkDownloadInvoice() {
      $uid = get_current_user_id();//changed for WordPress
      $cid = CRM_Core_BAO_UFMatch::getContactId($uid);//changed for WordPress
      if (CRM_Core_Permission::check('access CiviContribute') ||
        (CRM_Core_Permission::check('view my invoices') && $_GET['cid'] == $cid)
      ) {
        return TRUE;
      }
      return FALSE;
    }
  
  Hope it helps someone in future. :)
  
  > **Comments:**
  > **username_2**: You should put this in the issue queue  
  
  ---
  
  