Remove the Edit button in posts for permalinks on certain user roles? WP 3.3

I am using WordPress 3.3.2 with the following plugin:
http://wordpress.org/extend/plugins/advanced-access-manager/

The plugin works perfectly but the author said there is currently no way to achieve this from the plugin, So I am wondering if there is either another plugin or any code modifications I can make to achieve them.

Read More
  1. I created a custom user role Called “Member”
  2. I applied certain permissions so the user can only sees options to make posts in the backend.
  3. When making a post, the user does not see the “Edit” option to change the permalink.

  4. The problem comes after the user submits the Post. Right below the post title field it shows the permalink and shows an “Edit” button which allows the user to change the permalink.

Is there any way to remove either the “Edit” button so they can’t edit the permalink, or removing that entire line altogether so the permalink doesn’t show for them at all?

Thank you in advance!

Related posts

Leave a Reply

3 comments

  1. You could do something like (in your functions.php file);

    if(current_user_can('member')){  
    
    add_filter('get_sample_permalink_html', 'perm', '',4);
    
    function perm($return, $id, $new_title, $new_slug){
        
        $post = get_post( $id );
    
        if( ! $post || ( $post->post_type !== 'testimonials' ) )
        {
            return $return;
        }
    
        return preg_replace(
            '/<span id="edit-slug-buttons">.*</span>|<span id='view-post-btn'>.*</span>/i', 
            '', 
            $return
        );
    }
    

    To give credit where credit is due, everything between

    if( $_GET['role'] == "member" ) {

    and

    }

    …is directly taken from this Question & Answer HERE courtesy of Jonathan Wold

    UPDATE

    The conditional if statement of;

    if( $_GET['role'] == "member" ) {//code here }

    was replaced with,

    if(current_user_can('member')){ //code here}

    …in this instance.

  2. Just to provide an additional to accomplish this, the following code worked for me as well but it didn’t make use of the IF statement for the user role. This would be added to the functions.php file. I found the information at:
    https://gist.github.com/1967124

     <?php
    
    add_action('admin_head', 'hide_edit_permalinks_admin_css');
    
    function hide_edit_permalinks_admin_css()
    {
        ?>
    <style type="text/css">
    <!--
    #titlediv
    {
    margin-bottom: 10px;
    }
    #edit-slug-box
    {
    display: none;
    }
    -->
    </style>
    <?php
    }
    
  3. // get the role object
    $role = get_role( 'editor' );
    
    // remove cap
    $role->remove_cap( 'edit_post' );
    

    Not sure but this should work, isn’t it?