Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Buddy Registration Link

  • Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    I currently use my BuddyPress registration link by including the link in a test just liks this >> “To participate in Forums and Groups <font color = “#306EFF”>REGISTER</font> here.”

    I put this on the side bar using the text widget. But the problem is that the text and link remains even after the person registers and signs in.

    How do make disappear it disappear once the user signs in?

    The problem persist when I use the same method for “Lost Password” function

Viewing 25 replies - 1 through 25 (of 27 total)
  • Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Try doing something like this.

    <?php if ( !is_user_logged_in() )  {?>
     <font color = “#306EFF”>REGISTER</font>
     <?}?>
    Avatar of Hugo
    Hugo
    Moderator

    @hnla

    <font> is a deprecated & obsolete element and has been since the very early days of Standards and separation of presentation from data, if you have to add style try and do so from stylesheets, but if having to work directly on markup add the styles as ‘inline’ using the style attribute.

    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    @mgrmn
    I entered it like this:

    <?php if ( !is_user_logged_in() ) {?>
    To participate in Forums and Groups <font color = “#306EFF”>REGISTER</font> here
    <?}?>

    with the text widget and placed on the side bar but when a user logs in they could still see the “Register Message” although they can’t register once they are logged in. That is, the register page wasn’t loading anymore.

    @hnla
    Is your advice that I should remove <font>? If so, can I still use . Sorry am a newbie, learning as I go. All advice is appreciated.

    Thanks
    Benjamin

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Can you post your exact code snippet as you put it, not loading probably means a typo in the code.

    You can get an example code from http://codex.wordpress.org/Function_Reference/is_user_logged_in , it pretty straight forward. Not much coding knowledge needed.

    And what @hnla means is that <font> tag has been deprecated, so use css something like

    <p style="color:#306EFF;">REGISTER HERE</p>

    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    “<?php if ( !is_user_logged_in() ) {?>
    To participate in Forums and Groups <font color = “#306EFF”>REGISTER</font> here
    <?}?>”

    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    @mgrmn
    I don’t know what is wrong but its not loading. here is the link.
    REGISTER

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Sorry I think, I see what you are trying to do, you are using a default Text Widget from wp admin-> Appearance -> Widgets -> A text Widget with the code you posted?

    If so you can do the following

    /wp-content/themes/YOURTHEME/fucntions.php (create functions.php it if does not exist)

    than add this piece of code to the functions.php

    add_filter('widget_text','execute_php',100);
    function execute_php($html){
         if(strpos($html,"<"."?php")!==false){
              ob_start();
              eval("?".">".$html);
              $html=ob_get_contents();
              ob_end_clean();
         }
         return $html;
    }

    Now you can go to widgets and add a Text Widget to your sidebar and add a code like this

    <?php 
    if ( !is_user_logged_in() ) {
     echo "you are NOT logged in";
    } else {
     echo "you are logged in";
    }
    ?>
    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    @mgrmn Sorry for sounding so dumb. Can I put the code below with the text widget.
    Please reply with an example. Like using example.com/register

    <?php
    if ( is_user_logged_in() ) {
    echo ‘Welcome, registered user!’;
    } else {
    echo ‘Welcome, visitor!’;
    }
    ?>

    Thanks in advance.
    Benjamin

    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    @mgrmn
    [I see what you are trying to do, you are using a default Text Widget from wp admin-> Appearance -> Widgets -> A text Widget with the code you posted?]

    Your above statement is correct.

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Dumb was me, did not read correctly your question (sorry) updated my answer 11 minutes ago, try that, I tested it locally and works fine :) the echo part you can change with your register code.

    like echo '<a href="#">LINK</a>';

    I put this on the side bar using the text widget.

    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    @mgrmn
    Thanks for the detailed explanation. I done the one for function.php
    But I need a bit of explanation about the one below. Sorry in advance for disturbing you.

    <?php
    if ( !is_user_logged_in() ) {
    echo “you are NOT logged in”;
    } else {
    echo “you are logged in”;
    }
    ?>
    Where should I put the link below in this above code lines? >>
    echo’REGISTER HERE ‘;

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Don’t worry,

    The first part what you added in functions.php will make sure that we can put in php code into the Text Widget, this is normally not allowed. It will simply not parse the php code. And that is the reason why u don not see the desired results on your screen.

    So now you can add a Text Widget and put in PHP code

    So now the notice when a user is or is not logged in. In php ! means IS NOT as in !=, so here we go with your code

    <?php
    if ( !is_user_logged_in() ) { /* if the user != logged in */
    echo "<a href='http://www.disqusnow.co.uk/register-2/'>Register</a>";  /* echo the link*/
    } else { /* else if user is logged in */
    echo "Welcome Back";  
    } /* closing the if else statement */
    ?>
    
    
    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Change the the http part, in echo "<a href='/register-2/'>Register</a>";

    so it becomes this using http will give problems do to the eval()

    
    <?php
    if ( !is_user_logged_in() ) { /* if the user != logged in */
    echo "<a href='/register-2/'>Register</a>";  /* echo the link*/
    } else { /* else if user is logged in */
    echo "Welcome Back";  
    } /* closing the if else statement */
    ?>
    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    @mgrmn

    I put the code below in the text widget but it just displaying the code on the site.
    <?php
    if ( !is_user_logged_in() ) { /* if the user != logged in */
    echo “Register“; /* echo the link*/
    } else { /* else if user is logged in */
    echo “Welcome Back”;
    } /* closing the if else statement */
    ?>

    Thanks for all your help so far.

    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    @mgrmn

    I ran the code on php code test site and it showed the message below:
    Fatal error: Call to undefined function is_user_logged_in() on line 2

    Avatar of bp-help
    bp-help
    Participant

    @bphelp

    @disqusnow
    This will fix you up as long as you added that code to enable php in widgets!

    
    <?php
    if ( !is_user_logged_in() ) {
    ?><a href="<?php echo (bloginfo('url') . '/register');?> ">Register</a><?php
    } else {
    echo "Welcome Back";
    }
    ?>
    
    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Can you send me your functions.php ? ol4pro at gmail.com (zip it first)

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Or give me access to your admin panel (temporary)

    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    @mgrmn

    Thanks for all your help. I have emailed you the functions.php zip file.
    I can give you the wordpress admin panel if you think its the better option.

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Ok updated your functions.php, you added the code after the ?> closing tag at the bottom of your functions.php so, whatever php code you put in your widget would still not be parsed.

    Now can do a simple test by just creating a text widget with the following

    <?php
    echo “Yes, php parsing works”;
    ?>

    If the output of that is Yes, php parsing works without the echo” “; part You are set :)

    Avatar of disqusnow
    disqusnow
    Participant

    @disqusnow

    @mgrmn I have emailed you. Hope you received it.

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Yes I did, and replied, its not the code, but rather the code in your text widget.
    You probably used something like echo (bloginfo(‘url’) . ‘ which will echo out http, eval and http will have problems so you have to use something like /register-2/ instead

    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    There you go…

    When you copy and paste code from here the “<– Quotation marks like those are copy and pasted wrongly!
    Ill adjust your text widget with your register code :) give me a few secs

    All done :) Have fun!

    Avatar of bp-help
    bp-help
    Participant

    @bphelp

    @disqusnow
    If you add this code to the text widget it will work. I just noticed your register slug is different so I adjusted the code below. Tested and works!

    
    <?php
    if ( !is_user_logged_in() ) {
    ?><a href="<?php echo (bloginfo('url') . '/register-2');?> ">Register</a><?php
    } else {
    echo "Welcome Back";
    }
    ?>
    
    Avatar of mgrmn
    mgrmn
    Participant

    @mgrmn

    Nice.. I am glad it all Finally worked out for ya :)

Viewing 25 replies - 1 through 25 (of 27 total)

You must be logged in to reply to this topic.