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 Q2A Core by
edited by

Because I want new users to first go through a training video and pass a quiz before using the site, I want to remove the registration capabilities here, see photo.  I'm new to php, and I imagine these items are internationalized too, making it harder to locate what part of the code offers these register options. 

Can you please show me what part of the q2a code I need to alter, AND I DO NOT MIND HAVING TO ALTER THE CODE BY HAND IN A FOLLOW-ON RELEASE, AND AS SUCH PREFER THIS METHOD RATHER THAN (LEARNING) CREATING A PLUGIN. THANKS.

Q2A version: 1.7.5 LATEST

1 Answer

+1 vote
by

There is no need to change the text. I guess you're thinking about turning into an empty string. That won't really work as the http://yousite.com/register page will still be available. The best thing to do (without using a plugin) would be to remove from the core the route to that page so that the core is not aware of it anymore. Then, just remove the link.

Follow these steps:

1. Edit file qa-include/qa-page.php and locate this line: https://github.com/q2a/question2answer/blob/e17b0e3319e84d8a3f38ea56dc0f1a093fa96360/qa-include/qa-page.php#L445

2. Change it to:

// 'register' => 'pages/register.php',

3. Edit file qa-include/app/users.php and locate this line: https://github.com/q2a/question2answer/blob/e17b0e3319e84d8a3f38ea56dc0f1a093fa96360/qa-include/app/users.php#L549

4. Change it to:

'register' => '',

by
Hi RayDev. I'm happy to know you have a good cause to spend your time on. I also have a couple, and for the ones I don't have time, I invest (donate) money on them.

For the time being (and for the last couple of years) one of those causes has been Q2A. I've spent over 2000 hours either adding new features or bugfixes to the core, as well as developing plugins. You can see my 96 pull requests to the GitHub project here: https://github.com/q2a/question2answer/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Apupi1985%20 where even 4 of them have been this month. Your users, and yourself, right now while you read this, are most likely executing code I've written (not only me of course, this is mostly Gideon's and Scott's work). Not to mention the time it takes me to answer questions as well as comments in this site.

Working in your cause will move me away from mine, which is not what I want at the moment. The good thing is that working in my cause would also help you in yours, as you, as well as many other people who work in good causes, clearly depend on Q2A. It'd be unfair to focus only in yours.

Anyway, you can make use of my time by asking any (answerable) question you have. If it is clearly explained and it is not the "What are the steps to fly to the moon?" kind of questions, I'll do my best to answer it. Bear in mind, in many cases that will only show you the door, you're the one has to walk through it :)

BTW, GET or POST requests are the same for your objective. Just send the parameter and process it the server.
by
edited by
Thanks for your reply, and all you contribute, HERE AND ELSEWHERE.  It is appreciated Brother.

As I don't know PHP, but am learning, can you please just give a quick outline of the code, just 3 minutes of your time.  Note, others want to have a way to have folks pass some qualifications on using Q2A before allowing entry/registration, so it will be useful for others.
by
I don't know if you see it Brother, but your response has an air of "competition" in it ... "who gives the most."   THERE IS NO COMPETITION.  LOVE SERVES ALL.  PLEASE GIVE NOW A ... LITTLE MORE ... OF YOUR TIME ... BROTHER
by
Not really. What I wanted to say (maybe I didn't find the appropriate words) is that I'm already contributing quite a lot of my time to Q2A. So when you ask me to help you, even if I hadn't answered your question or all the comments, I wanted to make it clear that I'm already helping you. So rather than asking for my help your asking for more of my help. That's fine, but it is up to me (and my schedule) if I will give even more.

Don't worry, I will. The answer to your extra help request is this:

1. Learn some Basic/Intermediate PHP (essential)
2. Learn this http://docs.question2answer.org/plugins . Note I'm saying "learn" not just "read". That also means you'll have to spend many (MANY) hours reading and writing code, making tests, failing. But eventually you'll succeed. You could take a look at 'page' module and 'layer' in particular as those are most likely the ones you'll be needing.
3. Use the layer to configure the appropriate register links (it is better than the approach that I suggested in my answer, of course)
4. Use the page module to create a new login section that will ask whatever field you need
5. When submitting a form in the new page, submit it against the actual register page and load it with some hidden field
6. Go to the layer again and add some code that checks that if you are displaying the register page AND you DO NOT have the hidden field set it will redirect to your custom page

This is obviously not bullet proof as anyone could create a POST against the register page with the additional hidden field but is one of the easiest approach.

Additionally, you could just add some JS to the 'onclick' event of the 'Register' link that would display a popup and then redirect to the register page. You can do that from the layer or even adding the JS directly to the header of the Admin section.

I've just showed you the door(s) in quite a lot of detail. Your move now
...