WordPress.org

Forums

Polylang
Buddypress register page (10 posts)

  1. miguelcortereal
    Member
    Posted 1 year ago #

    I'm using Buddypress but will not need the multilanguage feature on it, my site will have the community component only in English, that's what makes sense.

    The site registration process is handled by Buddypress overiding the WordPress default that makes use of /wp-signup.php to register a user.

    Buddypress use a blank wp page and applies its own register.php script to perform the registration fully compatible with WP users added with more collected data useful for BP profiles.

    With the exception of the community my whole site is multilanguage so far, included the registration process by using the solution pointed in this thread, however I was not able yet to make Buddypress display the registration link at top adminbar for each language registration page.

    Currently the link is mysite.com/register/ and I need it changing according each language to mysite.com/es/registro/ or mysite.com/pt/registar/ and so on.

    From what I could find the function that outputs the registration link is this one:

    /**
    	 * Returns the URL to the signup page
    	 *
    	 * @return string
    	 */
    	function bp_get_signup_page() {
    		if ( bp_has_custom_signup_page() ) {
    			$page = trailingslashit( bp_get_root_domain() . '/' . bp_get_signup_slug() );
    		} else {
    			$page = bp_get_root_domain() . '/wp-signup.php';
    		}
    
    		return apply_filters( 'bp_get_signup_page', $page );
    	}

    Just to clarify, bp_get_signup_slug() returns the slug from the mentioned blank wp registration page, usually register.

    I'm sorry Chouby, I know it's not at your todo list to provide Buddypress support for Polylang, but could you help on this one ? I know there's a filter to add for such cases but my skills don't go that far to figure out how to implement this.

    http://wordpress.org/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    I did not test but this may work

    add_filter( 'bp_core_get_directory_page_ids', 'pll_bp_core_get_directory_page_ids' );
    function pll_bp_core_get_directory_page_ids( $page_ids ) {
    foreach ($page_ids as $key => $id)
      $page_ids[$key] = pll_get_post($id);
    return $page_ids;
    }

    The expected result is that buddypress works with the page in current language provided that there is a translation for each page

  3. miguelcortereal
    Member
    Posted 1 year ago #

    And it does exactly what you expected it would, but there's a little bit more.

    All assigned Buddypress pages get unset, I've been looking into the code, BP tests what pages are in the pages array and remove everything that doesn't match the expected URIs.

    I've been also checking BuddyPress Multilingual plugin to make WPML compatible with BP and found this:

    add_filter('bp_uri', 'bpml_bp_uri_filter', 0);
    
    /**
     * Filters bp_uri.
     *
     * This URI is important for BuddyPress.
     * By that it determines some components and actions.
     * We remove language component so BP can determine things right.
     *
     * @param <type> $url
     * @return <type>
     */
    function bpml_bp_uri_filter($url) {
        global $sitepress;
        $default_language = $sitepress->get_default_language();
        if ($default_language == ICL_LANGUAGE_CODE) {
            return $url;
        }
        return preg_replace('/\/' . ICL_LANGUAGE_CODE . '\//', '/', $url, 1);
    
        echo $default_language;
    
    }

    Not sure if I'm right about the URI thing be the cause of the pages get removed, but this is contemplated on the compatibility plugin.

    May this function get adapted to Polylang ?

  4. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Yes for sure. Just replace:

    global $sitepress;
    $default_language = $sitepress->get_default_language();

    by

    $default_language = pll_default_language();

    But note that it works only when you add the language code to all urls.

    It would be even easier with Polylang 1.2 as the whole code should be:

    global $polylang;
    add_filter('bp_uri', array(&$polylang->links_model, 'remove_language_from_link'), 0);

    and should work whatever the option chosen for the language code.

  5. miguelcortereal
    Member
    Posted 1 year ago #

    Thanks a lot,

    I'll download Polylang 1.2, try the second option and also test the newer version since I have my site under construction.

  6. Maximo007
    Member
    Posted 1 year ago #

    Hello,
    where I mus paste this code? In function.php?

    /**
    	 * Returns the URL to the signup page
    	 *
    	 * @return string
    	 */
    	function bp_get_signup_page() {
    		if ( bp_has_custom_signup_page() ) {
    			$page = trailingslashit( bp_get_root_domain() . '/' . bp_get_signup_slug() );
    		} else {
    			$page = bp_get_root_domain() . '/wp-signup.php';
    		}
    
    		return apply_filters( 'bp_get_signup_page', $page );
    	}

    Thank you

  7. miguelcortereal
    Member
    Posted 1 year ago #

    You don't want to paste that code anywhere. It belongs to Buddypress Plugin.

  8. orionghf
    Member
    Posted 1 year ago #

    I followed the solution in the thread you mentioned .. but it seems that the code in step 2 where we are supposed to create theme templete buddymulti.php is not complete?

  9. orionghf
    Member
    Posted 1 year ago #

    Dear @miguelcortereal can you tell me how you managed to get the labels translated ?

    I only got some labels translated , but still some fields are not translated though the translaton is available in the po mo files.
    check this image please

    The translation is only fully available when I set the language in the wp-config file, but then the Arabic text appears in the english pages as well .. =\

  10. miguelcortereal
    Member
    Posted 1 year ago #

    @orionghf, Polylang doesn't support Buddypress.

    The only solution I know to have Buddypress multilanguage is by purchasing WPML plugin and add also BuddyPress Multilingual plugin.

    The solution pointed in this thread and the other thread mentioned above doesn't get Buddypress fully multilingual, only parts.

    In my case, my option was to intentionaly keep Buddypress only in English, I want my members from different languages interacting with each other.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.