Answers.Body: <p>You can check if the current user can edit an entry by using this  as your conditional:</p>
  
  <pre><code>{% if entry.isEditable() %}
      &lt;a href="{{ entry.cpEditUrl }}"&gt;Edit Page&lt;/a&gt;
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T16:05:10.110Z
Answers.Text: Does that work when adding that to your Base layout? I'm running the conditional in my base layout and it's not showing the link although the current author owns the page I'm testing.
Answers.UserDisplayName: Mark Busnelli Jr
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T16:09:49.007Z
Answers.Text: If you can access the entry model, then it should work fine. If you're adding it to the layout as opposed to the template you may be running into a scope issue. Try creating a {% block %} where the link should be and add the above code in the template under the newly created block.
Answers.UserDisplayName: Bryan Redeagle
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T16:28:13.673Z
Answers.Text: Hmmm that's not working for me on the front end. Is there something that I can do something with `{% if currentUser.can('permission') %} ... {% endif %}` ? I just don't know, nor can I find what `can()` can do :) I found `.can('createEntries:5')` but curious if there's a rendition of `.can('editEntries:5')` or something.
Answers.UserDisplayName: Mark Busnelli Jr
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T17:26:35.303Z
Answers.Text: The above should work. I would need to know way more before I could tell you why it's not. The function is really just a shortcut for a permission check. The one you're looking for is .can('publishEntries:5'). With 5 being the section id.
Answers.UserDisplayName: Bryan Redeagle
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-13T15:47:33.193Z
Answers.LastActivityDate: 2014-06-13T15:47:33.193Z
Answers.UserDisplayName: Bryan Redeagle
Body: <p>How would one go about showing a link on the front end if this entry belongs to the current user? I was thinking it had something to do with <a href="http://buildwithcraft.com/docs/templating/usermodel#can" rel="nofollow">the UserModel's <code>can()</code></a>, but I don't see any documentation of it.</p>
  
  <p>Right now I'm showing an "Edit Page" link once someone is logged in, but I don't want to show a that link on a page that the current user doesn't have access to edit.</p>
  
  <p>Any thoughts on this?</p>
  
  <p><em>Edit</em></p>
  
  <p>I was hoping something like this would work but it doesn't :( :</p>
  
  <pre><code>{% if entry.author == currentUser %}
      &lt;a class="btn btn-primary btn-small cp" href="{{ entry.getCpEditUrl() }}"&gt;Edit Page&lt;/a&gt;
  {% endif %}
  </code></pre>
  
Tags: <users>
Title: How can I grant front-end access to an entry that belongs to the current user?
ThreadText: # How can I grant front-end access to an entry that belongs to the current user?
  
  (Asked by: username_0 on 2014-06-13)
  
  How would one go about showing a link on the front end if this entry belongs to the current user? I was thinking it had something to do with [the UserModel's `can()`](http://buildwithcraft.com/docs/templating/usermodel#can), but I don't see any documentation of it.
  
  Right now I'm showing an "Edit Page" link once someone is logged in, but I don't want to show a that link on a page that the current user doesn't have access to edit.
  
  Any thoughts on this?
  
  *Edit*
  
  I was hoping something like this would work but it doesn't :( :
  
  ```
  {% if entry.author == currentUser %}
      <a class="btn btn-primary btn-small cp" href="{{ entry.getCpEditUrl() }}">Edit Page</a>
  {% endif %}
  
  ```
  
  **Tags:** users
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-06-13. Score: 5
  
  You can check if the current user can edit an entry by using this as your conditional:
  
  ```
  {% if entry.isEditable() %}
      <a href="{{ entry.cpEditUrl }}">Edit Page</a>
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Does that work when adding that to your Base layout? I'm running the conditional in my base layout and it's not showing the link although the current author owns the page I'm testing.  
  > **username_1**: If you can access the entry model, then it should work fine. If you're adding it to the layout as opposed to the template you may be running into a scope issue. Try creating a {% block %} where the link should be and add the above code in the template under the newly created block.  
  > **username_0**: Hmmm that's not working for me on the front end. Is there something that I can do something with `{% if currentUser.can('permission') %} ... {% endif %}` ? I just don't know, nor can I find what `can()` can do :) I found `.can('createEntries:5')` but curious if there's a rendition of `.can('editEntries:5')` or something.  
  > **username_1**: The above should work. I would need to know way more before I could tell you why it's not. The function is really just a shortcut for a permission check. The one you're looking for is .can('publishEntries:5'). With 5 being the section id.  
  
  ---
  
  