Home Forums Plugin Support WP User Frontend Pro No Edit Link at the post

This topic is: resolved

This topic contains 7 replies, has 2 voices, and was last updated by  Tareq Hasan 5 years, 11 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #4248

    csapoa
    Participant
    Post count: 11

    Hi there,

    I have created several posts on the site, but the edit link shows up only for the Admin, not for the user, who created the post.

    Can you help with this please?

    Thanks,
    Adrian

    #4255

    Tareq Hasan
    Keymaster
    Post count: 2831

    Hello Adrian,

    By default, WordPress doesn't give subscribers and contributors the capability to edit a post. They even don't give subscribers for posting, only contributors can submit a post but can't edit them. So it's a permission or capability problem.

    So for this problem, you could change the user roles or you could change/replace the default WP's edit link with yours. If you want to use a custom edit link only for WP User Frontend, use this snippet, it'll give you a edit link for current post.
    [php]
    if ( current_user_can( ‘delete_others_posts' ) || $post->post_author == get_current_user_id() ) {
    $edit_page = (int) wpuf_get_option( ‘edit_page_id', ‘wpuf_general' );
    $url = add_query_arg( array(‘pid' => $post->ID), get_permalink( $edit_page ) );

    printf( ‘<a href="%s">%s</a>', wp_nonce_url( $url, ‘wpuf_edit' ), __( ‘Edit', ‘wpuf' ) );
    }
    [/php]

    #4279

    csapoa
    Participant
    Post count: 11

    I see. Thank you for the reply!

    Can I place the above code to the single.php or somewhere else to have the edit available for all the posts for the user, who created it?

    Thanks,
    Adrian

    #4280

    Tareq Hasan
    Keymaster
    Post count: 2831

    Yeah, replace the edit_link code with this code.

    #4547

    csapoa
    Participant
    Post count: 11

    I cannot find this edit_link code, could you tell me where is it? (file and line)

    Thanks very much!

    Adrian

    #4553

    Tareq Hasan
    Keymaster
    Post count: 2831

    the edit_link is in your theme, not in the plugin. That code is responsible for displaying the post edit link. If you don't find it, insert the code where you want to show your edit link.

    #4935

    csapoa
    Participant
    Post count: 11

    Hi Tareq,

    I've put the code in the functions.php, but doesn't work. Is this the file that I have to edit? Or should this code be inserted in a different file?

    Thanks,
    Adrian

    #4939

    Tareq Hasan
    Keymaster
    Post count: 2831

    I've already mentioned it's your theme and look into single.php.

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘No Edit Link at the post’ is closed to new replies.