Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.4k views
in Q2A Core by
edited
Using Q2A Demo Sandbox the User link changes depending on the URL structure selected:

1.   /123/why-do-birds-sing (requires htaccess file)   --- >  http://demo.question2answer.org/user/Demo+Admin
2.   /index.php/123/why-do-birds-sing     --- > http://demo.question2answer.org/index.php/user/Demo+Admin
3.   /?qa=123/why-do-birds-sing    --- >  http://demo.question2answer.org/?qa=user/Demo+Admin
4.   /?qa=123&qa_1=why-do-birds-sing   ---- > http://demo.question2answer.org/?qa=user&qa_1=Demo+Admin
5.   /index.php?qa=123&qa_1=why-do-birds-sing  ---- > http://demo.question2answer.org/index.php?qa=user&qa_1=Demo+Admin

However when Q2A is integrated with Wordpress the User links do not change no matter which URL structure is selected: - always of the form ---> user/username  - and these links give a 404 error message when selected.

Does anyone know which files need to be changed to correct this error?

Thanks

 

Added:

I can reach the correct page by manually entering the link:

index.php?qa=user&qa_1=username

does this help??
Q2A version: 1.6.2

2 Answers

0 votes
by
edited by

Improved Fix - appears to work with all the URL structures:

I have made these changes to qa-include/qa-external-users-wp.php

 

function qa_get_logged_in_user_html($logged_in_user, $relative_url_prefix)
    {

        if (!isset($neaturls)) {
            require_once QA_INCLUDE_DIR.'qa-app-options.php';
            $neaturls=qa_opt('neat_urls');
        }

        switch ($neaturls) {
            case QA_URL_FORMAT_INDEX:
                $url='index.php/user/';
                break;
                
            case QA_URL_FORMAT_NEAT:
                $url='user/';
                break;
                
            case QA_URL_FORMAT_PARAM:
                $url='?qa=user/';
                break;
                
            case QA_URL_FORMAT_PARAMS:
                        $url='?qa=user&qa_1=';
                break;

            default:
                $url='index.php?qa=user&qa_1=';

        }


        $publicusername=$logged_in_user['publicusername'];

        return '<a href="'.htmlspecialchars($relative_url_prefix.$url.urlencode($publicusername)).
            '" class="qa-user-link">'.htmlspecialchars($publicusername).'</a>';
    }


    function qa_get_users_html($userids, $should_include_link, $relative_url_prefix)
    {
        $useridtopublic=qa_get_public_from_userids($userids);
        

        if (!isset($neaturls)) {
            require_once QA_INCLUDE_DIR.'qa-app-options.php';
            $neaturls=qa_opt('neat_urls');
        }

        switch ($neaturls) {
            case QA_URL_FORMAT_INDEX:
                $url='index.php/user/';
                break;
                
            case QA_URL_FORMAT_NEAT:
                $url='user/';
                break;
                
            case QA_URL_FORMAT_PARAM:
                $url='?qa=user/';
                break;
                
            case QA_URL_FORMAT_PARAMS:
                        $url='?qa=user&qa_1=';
                break;

            default:
                $url='index.php?qa=user&qa_1=';

        }


        $usershtml=array();


        foreach ($userids as $userid) {
            $publicusername=$useridtopublic[$userid];
            
            $usershtml[$userid]=htmlspecialchars($publicusername);

            if ($should_include_link)
                $usershtml[$userid]='<a href="'.htmlspecialchars($relative_url_prefix.$url.urlencode($publicusername)).
            '" class="qa-user-link">'.htmlspecialchars($publicusername).'</a>';
        }
            
        return $usershtml;
    }

 

 

 

0 votes
by

You can fix this by changing this in two places in qa-external-users-wp.php:

htmlspecialchars($relative_url_prefix.'user/'.urlencode($publicusername))

... to ...

qa_path_html('user/'.$publicusername)

Using Q2A's qa_path_html(...) function automatically builds the relative URL as appropriate.

This fix will be rolled in Q2A 1.6.3, also in the example qa-external-users.php file.

...