Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter dannyblank

    (@dannyblank)

    I worked it out 🙂

    <?php
    $customer_id = get_current_user_id();
    
    if( $customer_id == 1 ){ ?>
        <div id="miffy">Company<br/><?php /* the_author_meta( 'nickname', $userID ); */?>001</div>
        <div id="miffy">Manufacturer<br/><?php /* the_author_meta( 'nickname', $userID ); */?>Apple</div>
        <div id="miffy">OEM Code<br/><?php /* the_author_meta( 'nickname', $userID ); */?>M1960G/A</div>
    <div id="miffy">Grade A Quantity<br/><?php echo get_editable_post_meta( get_the_ID(), 'ebbage', 'input', true ); ?></div>
    <div id="miffy">Grade B Quantity<br/><?php echo get_editable_post_meta( get_the_ID(), 'radio', 'input', true ); ?></div>
    <div id="miffy">Grade C Quantity<br/>&pound;<?php echo get_editable_post_meta( get_the_ID(), 'mark', 'input', true ); ?></div>
    <div style="height: 10px; clear: both;"></div>
    <?php } else { ?>
        <div id="miffy">Company<br/><?php /* the_author_meta( 'nickname', $userID ); */?>001</div>
        <div id="miffy">Manufacturer<br/><?php /* the_author_meta( 'nickname', $userID ); */?>Apple</div>
        <div id="miffy">OEM Code<br/><?php /* the_author_meta( 'nickname', $userID ); */?>M1960G/A</div><div id="miffy">Quantity<br/><?php echo get_post_meta( get_the_ID(), 'ebbage', 'input', true ); ?></div>
    <div id="miffy">Grade<br/><?php echo get_post_meta( get_the_ID(), 'radio', 'input', true ); ?></div>
    <div id="miffy">Price<br/>&pound;<?php echo get_post_meta( get_the_ID(), 'mark', 'input', true ); ?></div>
    <div style="height: 10px; clear: both;"></div>
    <?php } ?>
    Thread Starter dannyblank

    (@dannyblank)

    Thanks catacaustic

    Its very close,

    i just tried this and it works!

    <?php
    $customer_id = get_current_user_id();
    
    if( $customer_id == 1 ){ ?>
        <div id="miffy">Company1<br/><?php the_author_meta( 'nickname', $userID ); ?></div>
    <div id="miffy">Quantity1<br/><?php echo get_editable_post_meta( get_the_ID(), 'ebbage', 'input', true ); ?></div>
    <div id="miffy">Grade1<br/><?php echo get_editable_post_meta( get_the_ID(), 'radio', 'input', true ); ?></div>
    <div id="miffy">Price1<br/>&pound;<?php echo get_editable_post_meta( get_the_ID(), 'mark', 'input', true ); ?></div>
      <?php
    
    } else {
       echo "<p>Default text.</p>";
    }
    ?>

    However, i want the else to also allow php so i need to remove the second part echo "<p>Default text.</p>";

    So it looks something like this;

    <?php
    $customer_id = get_current_user_id();
    
    if( $customer_id == 1 ){ ?>
        <div id="miffy">Company1<br/><?php the_author_meta( 'nickname', $userID ); ?></div>
    <div id="miffy">Quantity1<br/><?php echo get_editable_post_meta( get_the_ID(), 'ebbage', 'input', true ); ?></div>
    <div id="miffy">Grade1<br/><?php echo get_editable_post_meta( get_the_ID(), 'radio', 'input', true ); ?></div>
    <div id="miffy">Price1<br/>&pound;<?php echo get_editable_post_meta( get_the_ID(), 'mark', 'input', true ); ?></div>
      <?php
    
    } else {
    <div id="miffy">Company<br/><?php the_author_meta( 'nickname', $userID ); ?></div>
    <div id="miffy">Quantity<br/><?php echo get_post_meta( get_the_ID(), 'ebbage', 'input', true ); ?></div>
    <div id="miffy">Grade<br/><?php echo get_post_meta( get_the_ID(), 'radio', 'input', true ); ?></div>
    <div id="miffy">Price<br/>&pound;<?php echo get_post_meta( get_the_ID(), 'mark', 'input', true ); ?></div>
    }
    ?>
    Thread Starter dannyblank

    (@dannyblank)

    What we want to do is literally show or hide custom fields within woocommerce post types by user id.

    We do not need to use roles such as subscriber etc, this would need to be purely on a per user basis.

    Ideally something such as:

    <?php if ($current_user->user_login == '5') { ?>
    <div id="miffy">Quantity<br/><?php echo get_editable_post_meta( get_the_ID(), 'quantitiy', 'input', true ); ?></div>
    <?php } else { ?>
    <div id="miffy">Size<br/><?php echo get_editable_post_meta( get_the_ID(), 'size', 'input', true ); ?></div>
    <?php } ?>

    Thank you very much for your reply, really appreciated!

    Thread Starter dannyblank

    (@dannyblank)

    Ive fixed it!

    As im setting the site up i had one post assigned to multiple categories.

    This was causing the logo image to inherit from the last listed category.

    I can confirm the working code is

    <?php if (in_category('manchester-united')) { ?>
    <p>This is the Manchester United category</p>
    
    <?php } elseif (in_category('norwich-city')) { ?>
    <p>This is the Norwich City category</p>
    
    <?php } elseif (in_category('england')) { ?>
    <p>This is the England category</p>
    
    <?php } else { ?>
    <p>This is some generic text to describe all other category pages,
    I could be left blank</p>
    <?php } ?>

    Hope this help anybody that hasnt found a workaround!

    Thread Starter dannyblank

    (@dannyblank)

    Thanks ofr that but the site is in dev so i cant really share it at the moment as it is a client project!

    I am trying to achieve a different logo for each category and its corresponding posts under it.

    So Manchester Utd Category would display some kind of manchester united logo in the header! Etc Etc…..

    I can get the logo to show using the if (is_category) condition but that same logo will not remain for the categories posts.

Viewing 5 replies - 1 through 5 (of 5 total)