Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

  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!

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

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){
    global $post;
    if($post->post_type == 'testimonials')
    {
        $ret2 = preg_replace('/<span id="edit-slug-buttons">.*<\/span>|<span id=\'view-post-btn\'>.*<\/span>/i', '', $return);
    }

    return $ret2;
}

}

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.

share|improve this answer
    
Thank you for the reply and link! Would I edit the functions.php file from my theme, or from the wp-includes folder? I want to make sure if I upgrade WP, the change isn't lost... but if there is no way around that then no biggie :) –  Damainman Apr 22 '12 at 9:16
    
I tried putting that in both locations, with no success in either. –  Damainman Apr 22 '12 at 10:04
    
You should never edit the WP core files. Only edit files contained within your Themes/your-theme folder. Change testimonial to match your post type. If its just the regular post then type post. This code should go into your functions.php file within your theme folder. –  userabuser Apr 22 '12 at 12:28
    
Thanks for the reply and clarification on where to place the code. I've tried adding the code to both functions.php files(not at the same time of course).. I even changed the user to administrator and tried other post types. Tried capitalizing first letter of the member role as well. Tried putting it at the top and at the bottom of the functions.php page. I've spent about 4-5 hours googling hooks and functions and forums, but I still can not seem to get this to work. –  Damainman Apr 22 '12 at 15:07
    
Nm, the code works... just not with the IF statement. I am going to see what I can find. –  Damainman Apr 22 '12 at 15:34
show 6 more comments

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
}
share|improve this answer
    
Also here is another similar post: wordpress.stackexchange.com/questions/31627/… –  Damainman Apr 22 '12 at 16:36
add comment
// get the role object
$role = get_role( 'editor' );

// remove cap
$role->remove_cap( 'edit_post' );

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.