Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved]How to redirect registration page to activity?

  • @tatakatte

    Participant

    I’m running a WP 4.1 and BP 2.1.1. Here’s what I did and what I’m trying to do. I’ve chosen my registration page as my homepage http://freewall.net (still looking for ways to customize it).

    If you click the header link, you’ll be taken to the registration page (if logged out). If you are logged in, however, you’ll be redirected to http://freewall.net/members/, which is what I wanted to change to http://freewall.net/stream/.

    Is there a way for me to work on it?

Viewing 18 replies - 1 through 18 (of 18 total)
  • @henrywright

    Moderator

    Hi @tatakatte

    Try this:

    function my_login_redirect() {
        if ( is_user_logged_in() && bp_is_register_page() )
            bp_core_redirect( home_url() . '/stream/' );
    }
    add_action( 'template_redirect', 'my_login_redirect' );

    @tatakatte

    Participant

    Hi @henrywright

    I tried this little code but my site gave me this error

    Warning: Cannot modify header information - headers already sent by (output started at /home/emncrz/public_html/wp-content/plugins/bp-custom.php:9) in /home/emncrz/public_html/wp-includes/pluggable.php on line 1178

    I’m not really sure how this pluggable.php works. Sorry for being such a noob.

    @henrywright

    Moderator

    Where did you paste the code? It should go in your theme’s functions.php file.

    @bphelp

    Participant

    @tatakatte
    Did you put Henry’s code in with opening and closing php tags? Make sure there is no white space between the opening and closing php tags as this will give an headers already sent error.

    @bphelp

    Participant

    @tatakatte
    Should work fine in the themes functions.php as @henrywright specified or in bp-custom.php

    @tatakatte

    Participant

    It didn’t work. I tried placing the code both in functions.php and bp-custom.php 🙁

    @henrywright

    Moderator

    Were there any error messages? Can you describe what is happening when you add the code to functions.php?

    @tatakatte

    Participant

    Nothing happened. It’s still redirecting to /members/. I’m not really sure how I should put the opening and closing tags that @bphelp mentioned, but I just used /** and */ before and after the code you gave me.

    @bphelp

    Participant

    @tatakatte
    Maybe your slug is wrong in the URL. Try this:

    
    function my_login_redirect() {
        if ( is_user_logged_in() && bp_is_register_page() )
            bp_core_redirect( home_url() . '/activity/' );
    }
    add_action( 'template_redirect', 'my_login_redirect' );
    

    Reason being you may have changed the pages name but if you didn’t change the slug as well it wouldn’t work.

    @henrywright

    Moderator

    You don’t need the /** and */

    @tatakatte

    Participant

    @Here’s everything that I have in my functions.php

    <?php
    /**
     * @package WordPress
     * @subpackage
     * @author
     * @since 1.0
     */
    
    /**
     * Child Theme Functions
     * Add custom code below
    */ 
    
    function my_login_redirect() {
        if ( is_user_logged_in() && bp_is_register_page() )
            bp_core_redirect( home_url() . '/stream/' );
    }
    add_action( 'template_redirect', 'my_login_redirect' );

    As for @bphelp’s, the slug is really /stream/. I checked it after reading your reply, but it really is /stream/. Also shouldn’t it return a 404-error if it’s a non-existent page? Please correct me if my understanding is wrong.

    @henrywright

    Moderator

    And you’re definitely logged in and visiting your register page?

    @tatakatte

    Participant

    Unfortunately, yes 🙁

    @henrywright

    Moderator

    Try changing the last line to:

    add_action( 'template_redirect', 'my_login_redirect', 1 );

    @bphelp

    Participant

    @tatakatte
    Did you make sure you set your registration page as a static page in dashboard/settings/reading because I just tested it and it works as expected. On my dev environment when I go to the site without being logged in it redirects me to the registration page. Once I log in it redirects to the activity stream. Isn’t that what you wanted?

    @henrywright

    I didn’t use any priority and it worked so I don’t think that is the issue. Your code worked fine when I tested it as is.

    @tatakatte

    Participant

    @henrywright

    This one worked well. Now, it’s redirecting to /stream/!

    function my_login_redirect() {
        if ( is_user_logged_in() && bp_is_register_page() )
            bp_core_redirect( home_url() . '/stream/' );
    }
    add_action( 'template_redirect', 'my_login_redirect', 1 );


    @bphelp
    I’m not really sure why it required priority to work, maybe due to a plugin that I’m using?

    @henrywright

    Moderator

    @bphelp thanks for testing 🙂


    @tatakatte
    yeah, it’s likely something in your installation is already redirecting. The priority just makes sure my_login_redirect() is executed first.

    @tatakatte

    Participant

    I see… I have Theme My Login plugin installed. Maybe it could be causing the problem? Thanks for your help @bphelp and @henrywright! 😀

Viewing 18 replies - 1 through 18 (of 18 total)
  • The topic ‘[Resolved]How to redirect registration page to activity?’ is closed to new replies.
Skip to toolbar