Skip to:
Content
Pages
Categories
Search
Top
Bottom

Redirecting the bp_login_bar – almost got it!

  • Avatar of Devweb
    devweb
    Participant

    @devweb

    Hi all, need some help,

    I have the following in the bp_core_templatetags.php file:

    <form name=”login-form” id=”login-form” action=”<?php echo $bp->root_domain . ‘/wp-login.php’ ?>” method=”post”>

    <input type=”text” name=”log” id=”user_login” value=”<?php _e( ‘Username’, ‘buddypress’ ) ?>” onfocus=”if (this.value == ‘<?php _e( ‘Username’, ‘buddypress’ ) ?>’) {this.value = ”;}” onblur=”if (this.value == ”) {this.value = ‘<?php _e( ‘Username’, ‘buddypress’ ) ?>';}” />

    <input type=”password” name=”pwd” id=”user_pass” class=”input” value=”” />

    <input type=”checkbox” name=”rememberme” id=”rememberme” value=”forever” title=”<?php _e( ‘Remember Me’, ‘buddypress’ ) ?>” />

    <input type=”submit” name=”wp-submit” id=”wp-submit” value=”<?php _e( ‘Log In’, ‘buddypress’ ) ?>” />

    <input type=”button” name=”signup-submit” id=”signup-submit” value=”<?php _e( ‘Join up’, ‘buddypress’ ) ?>” onclick=”location.href='<?php echo bp_signup_page() ?>'” />

    <input type=”hidden” name=”redirect_to” value=”/members/<?php bp_core_get_username() ?>/profile” />

    <input type=”hidden” name=”testcookie” value=”1″ />

    This is the code for the form in the sign in bar on the home page. I want to use this to redirect the user to their profile page.

    All I need is a small piece of code that takes the username inputted into the ‘username’ box and places into ‘bp_core_get_username()’ above. The reason I know this must work is, if you replace that with the actual username and login with that username, it goes directly to the user profile page.

    Can someone please suggest the code needed to input the username?

    Thanks very much

    DevWeb

Viewing 3 replies - 1 through 3 (of 3 total)
  • Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    It’s tough to read big chunks of code like that above. Use the pastebin http://buddypress.pastebin.com

    Avatar of Devweb
    devweb
    Participant

    @devweb

    Thanks Burt, will remember in future, however, here is the line of code I am interested in:

    <input type=”hidden” name=”redirect_to” value=”/members/<?php bp_core_get_username() ?>/profile” />

    As per the original post I need some PHP script to call the username that the user has inputted into the username field – to replace the highlighted text above.

    Anyone have any suggestions please let me know!

    Thanks in advance

    DevWeb

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    You are talking about the function bp_login_bar() in the bp-core-templatetags.php file.

    The form field that you are interested in gets set by bp before it arrives at the user’s browser. You don’t know who the user is until they fill out the form and it gets sent back to the server for processing.

    Then they are logged in and you know who they are. It’s too late though because the redirect takes effect after login and they wind up at wherever the hidden field redirect sends them to.

    I think you want to modify the form data before it gets submitted and arrives at the server. You can’t do that using traditional form handling. You’ll have to modify the form data using javascript before it gets sent back to bp.

    You’ll have to investigate something like this:

    http://stackoverflow.com/questions/344451/modifying-form-data-before-submission

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

The topic ‘Redirecting the bp_login_bar – almost got it!’ is closed to new replies.