Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

PLUGIN DEV: How can I add dynamic url for suggest_requests() and match_request($request)

+1 vote
asked Aug 10 in Q2A Core by esqeudero

I want a plugin page url appear as


 I need to set suggest_requests() and match_request($request) at plugin page. So, I tried this one but it wont work.

function suggest_requests() 


$handle = qa_request_part(1);

return array(


'title' => 'Something',

'request' => 'user/'.$handle.'/something',

'nav' => 'M',




function match_request($request)


$handle = qa_request_part(1);


if(isset($handle) && qa_request_part(0) == 'user' && qa_request_part(2) == 'something'){

        return true;

    } else {

        return false;



when I go to "user/username/something" error appears stating page not found. Where I am doing wrong? 

Q2A version: q2a 1.7.5 customized
commented Aug 11 by pupi1985
What you're "doing wrong" is trying to overwrite a core route. Page modules can't overwrite any core route, that's why they execute later in the bootstrap process

1 Answer

+1 vote
answered Aug 10 by JackSiro
edited Aug 11 by JackSiro
Best answer

I can help you with this because it is something that I have had to overcome while working on my blog post plugin.  Please check out on this plugin. In fact simply download it from github https://github.com/JackSiro/Q2A-Blog-Post-Plugin and check the user layer file and see how to achieve what you are thinking of. All you need is to override the user pages and templates using your own layer in your plugin where you will then declare your own template and add your preferred url. 

function doctype()


if (qa_request_part(0) == 'user') {

$handle = qa_request_part(1);

$usersection = qa_request_part(2);

if (!strlen($handle)) {

$handle = qa_get_logged_in_handle();

qa_redirect(!empty($handle) ? 'user/' . $handle : 'users');



$userid = qa_handle_to_userid($handle);

if (!isset($userid))

return include QA_INCLUDE_DIR . 'qa-page-not-found.php';

$usershtml = qa_get_users_html(array($userid), false, qa_path_to_root(), true);

$userhtml = @$usershtml[$userid];

} else $userhtml = qa_html($handle);

if ($usersection == 'articles') {

$this->template = 'user-something';

$this->content = $this->qa_user_something($handle, $userhtml);//custom content 





All the best sir and fellow developer.

commented Aug 11 by esqeudero
I tired qa_set_template('user-someting'); but it wont work.

Jack you should also add if($class == 'nav-sub') in order your code to not conflict with other navigations.

function nav_list($navigation, $class, $level=null)
        if($class == 'nav-sub') {
            switch ( $this->template ) {
            case 'user':
            case 'user-wall':
            case 'user-activity':
            case 'user-answers':
            case 'user-articles':
                $navigation['articles'] = array(
                    'label' => qa_lang('bp_lang/nav_articles'),
                    'url' => qa_path_html('user/'.qa_request_part(1).'/articles'),
            case 'account':
            case 'favorites':
                $navigation['articles'] = array(
                    'label' =>qa_lang('bp_lang/nav_articles'),
                    'url' => qa_path_html('user/'.qa_get_logged_in_handle().'/articles'),

        qa_html_theme_base::nav_list($navigation, $class, $level=null);
commented Aug 11 by JackSiro
sorry sir for confusing you a bit. I forgot that I was only using qa_set_template in my core hacks. However this function does not work in custom code. Instead use $this->template as in my code in the answer I have just redited. I even rectified my plugin on github. Infact not that this is done in the doctype function only