Hide hard coded shopping cart

I created a new role subscriber2. It has the identical capabilities of subscriber but I need the differentiation for different plugins to work.

I only want a subscriber2 role of the CURRENT SITE- to be able to see the Marketpress shopping cart that is hard coded at the top of the framemarket theme because I do not have global cart enabled and it confuses buyers. I pasted this in to gridmarket's header.php:

<div id="header-wrapper">
<div id="header">
<?php
if (current_user_can('read'))
{?>
<?php if ( class_exists( 'MarketPress' ) ) {

$settings = get_option('mp_settings');
if (!$settings['disable_cart']) {
?>
<div id="cart-contents"><?php _e( 'Cart:', 'framemarket' ) ?> <span><?php echo sprintf(__('%s item(s)', 'framemarket' ), mp_items_count_in_cart()); ?></span></div>
<div id="mp-cartsmall">
<div id="toggle">
<?php _e( 'View Cart', 'framemarket' ) ?>

<?php _e( 'Hide Cart', 'framemarket' ) ?>
<?php
}?>
</div>
</div>

1) But subscribers from other blogs can see the cart and I don't want them to unless they are subscribers of the current blog. What code should I be using?
2) it is a paste of code from elsewhere:slight_smile: Did I insert it the statements properly ?

Thanks!

  • Arun Basil Lal
    • New Recruit

    Hey Atlanta,

    What you are using here is if (current_user_can('read')), which means if the user can just read the blog (which everyone can), he wold see it.

    You should be using if (current_user_can('subscriber2')). subscriber2 is only for the current blog, right?

    Let me know how that goes. Good luck!

  • 3SixtyEvolve
    • New Recruit

    Hi @Atlanta

    We haven't heard back from you, so I'm hoping you got sorted.

    I will go ahead and resolve this topic, but please don't hesitate to reopen it should you still require additional support from us. Just select the 'Mark as Not Resolved (re-open)' box below the post area (otherwise we might miss your new post).

    All the best!

    Gina

  • Atlanta
    • Syntax Hero

    Paul gave me this solution in live chat today. He said to create a new role with a new capability, eg mp_read and then change header.php in gridmarket to reflect the role's capabilities using user role editor capsman.
    He created this pastebin code

    http://pastebin.com/WbfSezVa

    The change is from

    <?php if ( class_exists( 'MarketPress' ) ) {

    to

    <?php if ((current_user_can('mp_view') && ( class_exists( 'MarketPress' ) )) {

    I get the white screen of death when I insert the code so I think that I am missing the closing tags or something.. can you tell me what is wrong with the code?

  • Arun Basil Lal
    • New Recruit

    Hey @Atlanta

    Change that to:

    <?php endif; ?>
    			<div id="header-wrapper">
    				<div id="header">
    					<?php if ((current_user_can('mp_view') && ( class_exists( 'MarketPress' ) ))
    						$settings = get_option('mp_settings');
    						if (!$settings['disable_cart']) {
    						?>
    									<div id="cart-contents"><?php _e( 'Cart:', 'framemarket' ) ?> <span><?php echo sprintf(__('%s item(s)', 'framemarket' ), mp_items_count_in_cart()); ?></span></div>
    						<div id="mp-cartsmall">
    									<div id="toggle">
    								<a id="open" class="open button" href="#"><?php _e( 'View Cart', 'framemarket' ) ?></a>
    
    							<a id="close" style="display: none;" class="close button" href="#"><?php _e( 'Hide Cart', 'framemarket' ) ?></a>
    
    							</div>
    						</div>
    						<?php } ?>

    Not 100% sure what @PaulM intended, but think it should work.

  • Dean Kaus
    • The Bug Hunter

    Hello @Elite Atlanta and @Arun I've discovered through much trial and mostly error that the majority of time when you encounter the white screen of death. The problem is usually not enough memory allocated from your server. Depending on which hosting company you have you may be ablel to do this yourself.

    From your Cpanel or virtualmin panel you need to go to php resources and increase the memory there. I just increased mine to 128 just to avoid having to readjust as my website is closer to completion or if I'm trying out other things.

    If you don't see the setting or can't adjust it yourself you can contact your hosting company and have them do it for you.

    I honestly don't recall if you need to make this same adjustment in the php.ininfile or not, I just know that as soon as I increased it on my server all of my white screen issues went away.

    Hopw this helps.

  • Paul
    • The Green Incsub

    @Dean Kaus, actually the simpler solution for the white screen is to FTP into your site edit the wp-config.php and enable WP_DEBUG to true.

    define('WP_DEBUG', true);

    By default this is set yo false and should be set to false on production sites as this will hide PHP warnings and errors. And because these PHP warnings/error are now hidden you get the blank screen.

    When you enable the WP_DEBUG you will then be shown the warning/error. It could be the memory limit issue. Of some other programming bug or plugin conflicts.

  • Atlanta
    • Syntax Hero

    Thanks, I still can't get it to work.

    If I use
    if ((current_user_can('mp_view') && ( class_exists( 'MarketPress' ) )) {
    then I get
    unexpected { error message.

    If I leave out the { and have 3 )))
    then I get
    syntax error, unexpected T_VARIABLE in /wp/content/themes/gridmarket/header.php on line 23 error message

    If I try 4 )))) instead of 3 then I get
    Parse error: syntax error, unexpected '}' in /wp-content/themes/gridmarket/header.php on line 48

    Suggestions?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.