Need to hide Add New Category Toggle on Marketpress

Hi, I was successful in hiding the Add New Category Toggle button when I was using tt marketpress frontend by adding this to the tt frontend css file. .tt_mp_fe#product_category-add-toggle{display:none;visibility:hidden;} Now I am not using the tt frontend plugin but still want to hide that button. I have tried adding a few variations to the code to a few different places with no luck. I have tried adding the following codes: div.mp_product_category-add-toggle {display:none;visibility:hidden;
} and #mp_product_category-add-toggle etc.... and .mp_product_category etc.... I tried adding the code variations to my custom css plugin, directly to the marketpress css file and finally creating the custom wp-admin file in the mu-plugins folder and adding it there. No luck so far so I am in need of a little direction. Thanks

  • aristath

    Hello there @Leslie, I hope you're well today!

    This is going to require some hacking but it should work...
    Try this:
    1. Download and install this plugin: https://wordpress.org/plugins/intuitive-category-checklist/

    2. Edit line 43 in the plugin file and change it from
    $defaults = array('taxonomy' => 'category');
    to
    $defaults = array('taxonomy' => 'product_category');

    3. delete lines 73-98 of the plugin:

    <?php if (!current_user_can($tax->cap->assign_terms)) : ?>
    	<p><em><?php _e('You cannot modify this taxonomy.'); ?></em></p>
    <?php endif; ?>
    <?php if (current_user_can($tax->cap->edit_terms)) : ?>
    	<div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children">
    		<h4>
    			<a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3">
    				<?php
    				/* translators: %s: add new taxonomy label */
    				printf(__('+ %s'), $tax->labels->add_new_item);
    				?>
    			</a>
    		</h4>
    		<p id="<?php echo $taxonomy; ?>-add" class="category-add wp-hidden-child">
    			<label class="screen-reader-text" for="new<?php echo $taxonomy; ?>"><?php echo $tax->labels->add_new_item; ?></label>
    			<input type="text" name="new<?php echo $taxonomy; ?>" id="new<?php echo $taxonomy; ?>" class="form-required form-input-tip" value="<?php echo esc_attr($tax->labels->new_item_name); ?>" tabindex="3" aria-required="true"/>
    			<label class="screen-reader-text" for="new<?php echo $taxonomy; ?>_parent">
    				<?php echo $tax->labels->parent_item_colon; ?>
    			</label>
    			<?php wp_dropdown_categories(array('taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new' . $taxonomy . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $tax->labels->parent_item . ' &mdash;', 'tab_index' => 3)); ?>
    			<input type="button" id="<?php echo $taxonomy; ?>-add-submit" class="add:<?php echo $taxonomy ?>checklist:<?php echo $taxonomy ?>-add button category-add-sumbit" value="<?php echo esc_attr($tax->labels->add_new_item); ?>" tabindex="3" />
    			<?php wp_nonce_field('add-' . $taxonomy, '_ajax_nonce-add-' . $taxonomy, false); ?>
    			<span id="<?php echo $taxonomy; ?>-ajax-response"></span>
    		</p>
    	</div>
    <?php endif; ?>

    That should do it... :slight_smile:

    I hope that helps!

    Cheers,
    Ari.

  • Leslie

    Hi Ari, Yes, this worked for one part of the problem. Thank you. I was able to hide the add new category toggle on the create product page. I am using easy blogs and if the user has a free account, they do not have access to normal dashboard and can not add new categories. If user is a paid user, they will have access to normal dashboard and will be able to get to this page via the categories tab under products
    edit-tags.php?taxonomy=product_category&post_type=product

    Here they can add new categories which will be a problem and make our global store a mess with too many categories that are similar etc.....
    so.... is there a way to get rid of that tab? Attached is a screenshot for further clarification.

  • aristath

    Hello again!

    You can do the following to restrict access to these menus on your dashboard:

    Create a new php file in your wp-content/mu-plugins folder on your site.
    So you should end up with something like this:
    wp-content/mu-plugins/restrict-access.php
    If the mu-plugins folder does not already exist in your wp-content folder then you can manually create it.
    In that file paste the following:

    <?php
    
    /*
     * Hide admin menus for non Network Admins
     */
    function custom_remove_admin_theme_remove_menus () {
        if( !current_user_can( 'manage_network' ) ) {
            global $menu;
            $restricted = array(
                __( 'Posts' ),
                __( 'Media' ),
                __( 'Links' ),
                __( 'Pages' ),
                __( 'Tools' ),
                __( 'Users' ),
                __( 'Settings' ),
                __( 'Comments' ),
                __( 'Plugins' ),
                __( 'QRcode'),
            );
            end ( $menu );
    
            while ( prev( $menu ) ) {
                $value = explode( ' ',$menu[key( $menu )][0] );
                if ( in_array( $value[0] != NULL ? $value[0]: '', $restricted ) ) {
                    unset( $menu[key( $menu )] );
                }
            }
    
            remove_menu_page( 'edit-comments.php' );
            remove_menu_page( 'themes.php' );
            remove_menu_page( 'plugins.php' );
            remove_menu_page( 'admin.php?page=mp_st' );
            remove_menu_page( 'admin.php?page=cp_main' );
            remove_submenu_page( 'edit.php?post_type=product', 'edit-tags.php?taxonomy=product_category&post_type=product' );
            remove_submenu_page( 'edit.php?post_type=product', 'edit-tags.php?taxonomy=brand&post_type=product' );
            remove_submenu_page( 'edit.php?post_type=product', 'edit-tags.php?taxonomy=model&post_type=product' );
            remove_submenu_page( 'edit.php?post_type=product', 'edit-tags.php?taxonomy=product_tag&post_type=product' );
        }
    }
    add_action('admin_menu', 'custom_remove_admin_theme_remove_menus', 10);

    In my example above I'm also removing some other menus from the dashboard, so you can manually edit it and customize it however you want.

    I hope that helps!

    Cheers,
    Ari.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.