Skip to:
Content
Pages
Categories
Search
Top
Bottom

Redirect buddypress registration page using functions.php


  • jessicana
    Participant

    @jessicana

    Hello

    I have two subdomains that I want to redirect their registration page to the main domain, how to do this using functions.php or wp-config.php?

    Please help
    Jessica

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

  • jessicana
    Participant

    @jessicana

    Any help? Please


    jessicana
    Participant

    @jessicana

    Hello

    I tried to redirect my subdomain registration page on [multsite] to the main domain site registration page. I used the following code in my child theme functions.php for the site which I want to redirect its registration page:

    //redirect to the registration page
    function MyRedirect() {
        if(is_page('register')) {
            wp_redirect( 'http://domain.com/register/', 301 );
            exit;
        }
    }
    add_action('template_redirect','MyRedirect');

    Interestingly, the above code did not work, .htaccess is not working as well. I am, for sure, missing something but I don’t know what! .htaccess code is:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^sub\.domain\.com$
    RewriteRule ^register/(.*)$ http://domain.com/register/$1 [R=301,L]

    Any help from you is highly appreciated as I am really stuck in this.

    Thanks in advance for all of you specially: @djpaul , @boonebgorges , @henrywright , @r-a-y , @danbp , @modemlooper , @imath , @shanebp .

    Jessica


    valuser
    Participant

    @valuser

    Though its NOT via using functions.php or wp-config.php a solution could be :

    Network activate a plugin like Quick Page/Post Redirect Plugin and set it on each sub-site

    Request url —> /register/

    Destination url —> http://mymainsite.com/register


    valuser
    Participant

    @valuser

    Have revisted this interesting query!

    Consulted this similar query

    and have come up with another possible solution
    (so long as the main site has a different theme or child theme to the other sites.)

    in functions.php of sub-sites’ themes insert

    add_action( 'template_redirect', 'redirect_to_specific_page' );
    
    function redirect_to_specific_page() {
    
    if (is_page('Register') && ! is_user_logged_in() ) {
    
    wp_redirect( 'http://yourmainsite.dev/register/', 301 ); 
      exit;
        }
    }

    would not work with slug is_page(‘register’}

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar