Skip to:

How to read bbPress Theme Switcher’s theme user choice cookie outside of bbPress

  • Hello,

    I would like to have bbPress in two languages, using the same forum DB. So when viewing in language 1, the forum’s interface would be in language 1 with all the postings listed, and in language 2, the interface would be in language 2 with the same postings listed.

    I plan on achieving this with bbPress theme switcher ( ) and the link to switch between the themes/languages would be /bbpress/?bbtheme=lang1 and /bbpress/?bbtheme=lang2

    I would also like to set up a php page at the root of the web domain to auto-detect and forward to the appropriate mediawiki language page based on

    1) user’s browser language preferences if this is a first time visit

    2) last connection’s languages preferences, which would be saved in the form of bbPress’s theme preference cookie.

    with a file structure of





    My code so far is:


    /* langdetect.php */

    $defaultlang = ‘en’

    $lang = $defaultlang;

    /* bbPress theme cookie detection */

    if cookie exists {

    (read cookie and set $lang to either en or ko.. bla bla)


    /* WordPress and/or MediaWiki last visit language detection */

    elseif previous visit info exists {

    (i’ll figure this out later)


    /* detect in-browser lang pref … modified from */

    else {

    $langlist = explode(‘,’, $_SERVER);

    foreach($langlist as $curLang) {

    $curLang = explode(‘;’, $curLang);

    /* use regular expression for language detection */

    if (preg_match(‘/(ko|en)-?.*/’, $curLang[0], $reg)) {

    $lang = $reg[1];





    /* redirect */

    if ( $lang==’ko’ ) { header( ‘Location: http://ENGLISHPAGE‘ ) ; }

    else { header( ‘Location: http://ENGLISHPAGE‘ ) ; }


    How can I read the bbPress cookie that contains the Theme Switcher theme preference?

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