WordPress.org

Ready to get started?Download WordPress

Forums

Trouble with plugin development (2 posts)

  1. fatwombat
    Member
    Posted 3 years ago #

    Hey, I have this code:

    add_action('plugins_loaded', 'check_language');
    
    function check_language(){
    
    	$userid = wp_get_current_user()->ID;
    
    	if(substr($_SERVER['REQUEST_URI'], 0, 6) == '/lang/'){
    		switch(substr($_SERVER['REQUEST_URI'], 6, 2)){
    
    			case 'en' : $language = 'english'; break;
    			case 'fr' : $language = 'french'; break;
    			default : $language = 'english'; break;
    
    		}
    
    		update_user_meta( $userid, 'language', $language );
    	}
    
    }

    Now it's in the plugin, but, it only ever stores french in the DB, can anyone see why this is? I am pulling my hair out cause I am surely missing something stupid.

    I have 2 pages under the parent of 'language' which are english and french. The URLS are:
    english: /lang/en/
    french: /lang/fr/

    Thanks in advance.

  2. fatwombat
    Member
    Posted 3 years ago #

    Anyone have any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic