[wp-trac] [WordPress Trac] #38130: Multisite bug with current_user_can() and subscriber

WordPress Trac noreply at wordpress.org
Thu Sep 22 19:14:46 UTC 2016


#38130: Multisite bug with current_user_can() and subscriber
-------------------------------+------------------------------
 Reporter:  JazZ7              |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Users              |     Version:  4.6.1
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:  multisite
-------------------------------+------------------------------

Comment (by JazZ7):

 Thanks for your support.

 Here is the code that handles the subscribers `upload_files` permission :
 (doing this in the template for demonstration)

 **/wp-content/themes/my-theme/profil.php** :
 {{{#!php
 <?php
 /*
 Template Name: Page Profile
 */

 $sub_role = get_role('subscriber');
 $sub_role->add_cap('upload_files');
 var_export($sub_role);

 echo "<br /><br />";

 $user_ID = get_current_user_id();
 $user = new WP_user($user_ID);
 var_export($user->caps);

 echo "<br /><br />";

 var_export(current_user_can('upload_files'));

 die();

 }}}

 The return is
 {{{
 WP_Role::__set_state(array( 'name' => 'subscriber', 'capabilities' =>
 array ( 'read' => true, 'level_0' => true, 'upload_files' => true, ), ))

 array ( 'subscriber' => true, )

 true
 }}}


 But the ajax request returns :
 {{{
 {'success': false, 'data':{'message': 'Sorry, you are not allowed to
 upload files.', 'filename': 'filename.jpg'}}
 }}}

 Any idea ? Need more infos ?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38130#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list