• So I almost have PHPBB Single Sign On plugin working, no errors in the WP admin – all green ‘OKs’ and PHPBB is set to wpbb authentication and works at least to display forums and posts.

    My logins are not working however.

    At first I when clicking on the Login link in PHPBB, I was getting “Cannot redeclare validate_username() (previously declared in …/wp-includes/registration.php:49 in ../forums/includes/functions_user.php on line 1610”

    I fixed this by adding a “if (!function_exists(‘validate_username’)) {” around the function in functions_user.php.

    Now I get the login screen, but when I enter my username and password and submit, it looks like it does something, then I get:

    “Cannot redeclare _wp_get_user_contactmethods() (previously declared in …/wp-includes/registration.php:326) in …/wp-content/plugins/phpbb-single-sign-on/module.wp.php(22) : eval()’d code on line 382”

    So the problem is I assume I need the version of this function from the plugin – I know I could comment out the one in registration.php, but I hate the idea of modifying the main code base.

    What do you think I should do? Is the plugin supposed to be overriding the function somehow? If so, why is it not working?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter SSzretter

    (@sszretter)

    So it seems like the problem must be the way this module is including the wordpress admin api and other code. I was able to get past this particular error by doing a replace string after the eval in module.wp.php:

    $include_admin_contents = str_replace('function _wp_get_user_contactmethods','function _wp_get_user_contactmethods_xxx',$include_admin_contents);

    However, next it gets stuck at:

    Call to undefined function  wp_update_user() in .../wp-content/plugins/phpbb-single-sign-on/module.wp.php on line 85

    So that leads me to believe even though it is including all kinds of wordpress stuff it is not including in the proper files/functions…??

    For anyone watching, this is what it is doing:

    $include_registration_contents = file_get_contents(ABSPATH . WPINC . '/registration.php');
                        $include_registration_contents = preg_replace('/^\<\?php/','',$include_registration_contents);
                        $include_registration_contents = preg_replace('/\?\>$/','',$include_registration_contents);
                        $include_registration_contents = str_replace('validate_username','op_validate_username',$include_registration_contents);
    
                        $include_admin_contents = file_get_contents(ABSPATH . '/wp-admin/includes/admin.php');
                        $include_admin_contents = preg_replace('/^\<\?php/','',$include_admin_contents);
                        $include_admin_contents = preg_replace('/\?\>$/','',$include_admin_contents);
                        $include_admin_contents = str_replace('require_once(ABSPATH . WPINC . \'/registration.php\');',$include_registration_contents,$include_admin_contents);
    
    					$include_admin_contents = str_replace('function _wp_get_user_contactmethods','function _wp_get_user_contactmethods_xxx',$include_admin_contents);  //  I ADDED THIS TO WORK AROUND 1 ERROR
    
                        eval($include_admin_contents);

    Thread Starter SSzretter

    (@sszretter)

    Figured it out at least 90% – I can log in on both sides (wordpress & phpbb), and I can register in wordpress. The only think that does not work for some reason is registering in phpbb. No specific error, but it just redraws the registration page without the captcha and a red “1” above the registration form.

    Anyway, I had to change thus function in module.wp.php in the plugin — all I did was comment out the lines below so it does not include the registration.php stuff:

    function loadAdminAPI(){
    		if(!function_exists('validate_username')){
    			require_once(ABSPATH . '/wp-admin/includes/admin.php');
    		}
    		else{
                        //$include_registration_contents = file_get_contents(ABSPATH . WPINC . '/registration.php');
                        //$include_registration_contents = preg_replace('/^\<\?php/','',$include_registration_contents);
                       // $include_registration_contents = preg_replace('/\?\>$/','',$include_registration_contents);
                        //$include_registration_contents = str_replace('validate_username','op_validate_username',$include_registration_contents);
    
                        $include_admin_contents = file_get_contents(ABSPATH . '/wp-admin/includes/admin.php');
                        $include_admin_contents = preg_replace('/^\<\?php/','',$include_admin_contents);
                        $include_admin_contents = preg_replace('/\?\>$/','',$include_admin_contents);
                        //$include_admin_contents = str_replace('require_once(ABSPATH . WPINC . \'/registration.php\');',$include_registration_contents,$include_admin_contents);
    
                        eval($include_admin_contents);
    		}
    	}

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: PHPBB Single Sign On] can not login (ucp) cannot redeclare’ is closed to new replies.