marketpress - user roles store settings

Some was covered here, thought I should maybe open a new thread rather than tack on. https://premium.wpmudev.org/forums/topic/restricting-access-to-marketpress

I am using adminimize and members to restrict and enable pages and have "edit_pages" "edit_others_pages" " edit_published_pages" enabled for Editor.

"Store settings" is the only tab option not available to the Editor.
I wish to enable "Coupons" under the "store settings" for the editor as this is important to the client to create/maintain - all the other settings in there are set and don't require access.

Any suggestions?

  • espsjurs

    Hi there,

    The add_submenu_page in line 586 of marketpress.php set the user level on this menu to 'manage_options'. This is an role for Administrator.

    It is not a god idea to change the user level of this menu because the 'Coupons' isnt a submenu but a section in 'Store settings'.

    The only way to fix this is to move the 'Coupons' to its own submenu. And I guess this would be a great idea for all of us!

    So the programmer should really look into this!

    Espen

  • Timothy Bowers

    Hey there.

    As Aaron wrote:

    You can customize the permissions if you would like via the filter 'mp_register_post_type'. The default uses to page permissions for maximum compatibility across installs.

    So you'd need to do something custom there.

    As a real quick solution you could edit marketpress.php line 4964 from:

    To something like:

    if (!$this->get_setting('disable_cart') && is_super_admin() ) {
        	$tabs = array(
                'coupons'       => __('Coupons', 'mp'),
        		'presentation'  => __('Presentation', 'mp'),
        		'messages'      => __('Messages', 'mp'),
        		'shipping'      => __('Shipping', 'mp'),
        		'gateways'      => __('Payments', 'mp'),
        		'shortcodes'    => __('Shortcodes', 'mp'),
        		'importers'     => __('Importers', 'mp')
        	);
        } else {
          $tabs = array(
             'coupons'       => __('Coupons', 'mp'),
    	'presentation'  => __('Presentation', 'mp'),
        	'shortcodes'    => __('Shortcodes', 'mp'),
    			);
        }

    That pretty much checks if your a Network admin, if so show all if not then display only coupons, presentation and shortcodes. You could remove them also.

    Just a quick solution for your problem.

    Take care.

  • espsjurs

    Hmmm,

    This is what I did:

    First I added the '&& is_super_admin()' to line 4964 and tested with a user with Editor role; No 'Store settings' submenu..

    Then I changed the 'manage_options' to 'edit_others_posts' in line 586 and tested again; The menu is there, but when I try it i get the 'Nice try..' message.

    Then I comment out the 'Nice try' check in line 4952-4955, and tested again; working as if 'disable_cart' is set.

    Then I changed the array for tabs from line 4964-4981 to add Coupons in line 4966, and tested again; working fine

    This will give Editors access to Coupons, Presentation, Shortcodes and Importers, but also the General tab - as might be a problem..

    The removal of the 'Nice try' check might also be a security problem..

    The 'General' tab might be removed by changing line 4987(4987) from $tabhtml[] = '<a href="' . admin_url( 'edit.php?post_type=product&page=marketpress' ) . '" class="nav-tab'.$class.'">' . __('General', 'mp') . '</a>'; to `if (is_super_admin()) {
    $tabhtml[] = '<a href="' . admin_url( 'edit.php?post_type=product&page=marketpress' ) . '" class="nav-tab'.$class.'">' . __('General', 'mp') . '</a>';
    } else {
    $tabhtml[] = '<a href="' . admin_url( 'edit.php?post_type=product&page=marketpress' ) . '"></a>';
    }`.

    Still there is a problem.. when entring the 'Store option' submenu as Editor the active tab is still 'General'. So it is still possible to access if the url is right (wrong). This might have something to do with the 'Nice try' check..

    But this is a plugin core change, and have to be done again after updates..

    EDITED!!

    yf
    Espen

  • mazza

    Timothy's quick solution didn't work on it's own (showed all tabs) so I also followed Espen's directions, bit of mix and match as for some reason it also didn't work straight up.

    First I added the '&& is_super_admin()' to line 4964 and tested with a user with Editor role; No 'Store settings' submenu..

    So swapped timothys code in.

    Then I changed the 'manage_options' to 'edit_others_posts' in line 586 and tested again; The menu is there, but when I try it i get the 'Nice try..' message.

    Then I comment out the 'Nice try' check in line 4952-4955, and tested again; working as if 'disable_cart' is set.

    I changed 4952 to 'edit_others_posts' and did not comment out the nice try, left that as is.

    Then I changed the array for tabs from line 4964-4981 to add Coupons in line 4966, and tested again; working fine

    I in the end added coupons and messages (thought client might find that also useful.)
    True that the general tab is still visible and I didn't try Espen's modifications in the end as happy that it's worked so far!
    Thanks Timothy/Espen!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.