WordPress.org

Forums

[resolved] Remove html text for logged in user (3 posts)

  1. chronicbubble
    Member
    Posted 2 years ago #

    The code I have put together works fine for what I need it to appart from the fact it still displays the message 'By registering, you can earn energy and collect rewards.' when a user is logged in (registered links to the registration wp-register.php register form).

    Basically I want it to display just 'You currently have 25 Energy Get more energy ' (get more energy links to a page) when a user logs in and not show "By registering, you can earn energy and collect rewards." as well underneath it.

    Then only display "By registering, you can earn energy and collect rewards." when a user is logged in (registered text links to the registration wp-register.php register form). when a user is logged out.

    I have tried commenting it out after the else statement but I don't know where I am going wrong. It has been placed inside my header.php file.

    Could someone kidnly fix this code for me?? Code is bellow. Many thanks in advance.

    <div style = "text-align:right;">
    
    <?php if ( $user_ID ) { ?>
    <img src="http://chronicbubbles.com/wp-content/uploads/2013/05/Energy_01_small.png" alt="energy" width="16" height="16">  You currently have <?php
        // We can call the function without passing any parameters.
        cp_displayPoints();
        // The points of the current user will be formatted with prefix and
        //  suffix and echo()'ed to the browser.?>  <b><a href="http://chronicbubbles.com/?page_id=35">Get more energy</a></b> 
    
    <?php } else { } ?>
    
    <p><img src="http://chronicbubbles.com/wp-content/uploads/2013/05/Energy_01_small.png" alt="energy" width="16" height="16"> By <a href="<?php bloginfo('http://chronicbubbles.com/'); ?>/wp-register.php">registering</a>, you can earn energy and collect rewards.</p>
    </div>
  2. vtxyzzy
    Member
    Posted 2 years ago #

    I am not totally sure, but I think this is what you want:

    <div style = "text-align:right;">
    
    <?php if ( $user_ID ) { ?>
    <img src="http://chronicbubbles.com/wp-content/uploads/2013/05/Energy_01_small.png" alt="energy" width="16" height="16">  You currently have <?php
        // We can call the function without passing any parameters.
        cp_displayPoints();
        // The points of the current user will be formatted with prefix and
        //  suffix and echo()'ed to the browser.?>  <b><a href="http://chronicbubbles.com/?page_id=35">Get more energy</a></b> 
    
    <?php } else { ?>
    
    <p><img src="http://chronicbubbles.com/wp-content/uploads/2013/05/Energy_01_small.png" alt="energy" width="16" height="16"> By <a href="<?php bloginfo('http://chronicbubbles.com/'); ?>/wp-register.php">registering</a>, you can earn energy and collect rewards.</p>
    <?php } ?>
    </div>
  3. chronicbubble
    Member
    Posted 2 years ago #

    Worked like a charm. Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic