Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
2.1k views
in Plugins by
So that users have to login only via Facebok?

This is a very safe way of getting spammers' hands off of your website

Is there a way to disable regular registration without core hack? I mean is there enough handles/hooks available?
Q2A version: qa 1.63
by
Please consider to pick up the accepted answer if amiyasahu's support is helpful to your question.

3 Answers

+2 votes
by
edited by

Yes , ofcourse it is possible - 

Just implement a layer by forllowing he tutorial of q2a and change the code accordingly 

the below code should do the job 

class qa_html_theme_layer extends qa_html_theme_base {
 
    function doctype() {
        if ($this->template=='register' && 
              isset($this->content['form']['hidden']['doregister']) && 
              !!@$this->content['form']['hidden']['doregister']) {
                        unset($this->content['form']);
         }
   }
}
Hope it helps 
 
Enjoy !!
 
by
Just seen this. Note the fact that not showing an HTML form doesn't mean the controller on the other side handling the HTTP POST won't log you in. It's like hiding sensitive information using the CSS rule "display: none" :)
by
agree! you mean visitors can still register by mySite.com/register
right?
by
then why the security code is being used in the Form . ?? is it useless . ??
by
edited by
You're definitely right. I thought about "stealing" the security code from other forms and reusing it in there. However, the security code has the template (action, actually) used as part of the hash and that "register" action is only sent in that controller, inside the form. Unsetting the form will not allow you to get the hash ever, so you will see the register page without the form that holds the hash so it will be impossible to register. Even HTTP POSTing to the register page will not allow you to see the hash because it also gets added to the form and removed in the theme while displaying failed results. Definitely a valid option.
0 votes
by
well, you can modify theme class and corresponding function output (html maybe)
+1 vote
by
edited by
You have several alternatives here. Firstly, the best way I can think of to "reject" a user registration is to send them to the home so I'm going to follow that approach in the following examples. I've listed them here based on how soon you want to reject the request (#1 is sooner than #2). 
 
1. Block access via .htaccess to the register URL or make a 302 redirect to your home. Make sure to make it case insensitive. PHP is not even involved in this stage.
 
2. Use a process plugin to catch the request and perform a 302 redirect (http://www.question2answer.org/modules.php?module=process) as soon as possible. Something like this should do the trick:
 
public function init_page() {
    if (qa_request() === 'register') {
        qa_redirect(''); // Also performs a 302 redirect to the home
    }
}
 
3. Use a plugin override (http://www.question2answer.org/overrides.php) and override function qa_page_routing(). In this case you just need to:
 
function qa_page_routing() {
    $routes = qa_page_routing_base();
    unset($routes['register']);
    return $routes;
}
 
4. Use a layer plugin and overwrite the doctype() function:
 
public function doctype() {
    if ($this->template === 'register') {
        qa_redirect(''); // Also performs a 302 redirect to the home
    }
}
 
5. Apply the same code in #4 in the qa-theme.php file
 
Finally, bear in mind that for #2, #3, #4 and #5 you should remove all links to the register page.
...