简体   繁体   中英

Custom Wordpress User role can't add image into post

I created a custom User role in Wordpress and I gave the role the ability to upload files. However, once you upload the files and try to insert them into the post, nothing happens. Here are the set of roles I provided which I believe should give the user access to insert images into the post.

 function add_guide_author_role() {
     $role = get_role( 'guide_author' );
     // create if neccesary
     if (!$role) $role = add_role('guide_author', 'Guide Author'); 
     // add theme specific roles
     $role->add_cap('delete_posts');
     $role->add_cap('edit_posts');
     $role->add_cap('edit_published_posts');
     $role->add_cap('read');
     $role->add_cap('upload_files');
 }

 add_action( 'admin_init', 'add_guide_author_role');

Am I missing a add_cap to give them the ability to add the images they uploaded into the post?

Thank you.

I'm not sure if you ever found the answer to this question, but if you change

 add_action( 'admin_init', 'add_guide_author_role');

to

 add_action( 'admin_menu', 'add_guide_author_role');

you might find that the problem goes away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM