Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
1.5k 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
Thanks for your response.  Will there still be a register page I can feed into (after they pass the quiz, only accessible there)?
by
No, this leaves no way of registering. This removes the register link and the /register URL making it inaccessible to everybody, based on "I want to remove the registration capabilities here".

Nobody will be able to register using the Q2A flow. You'll have to code your ad-hoc registration flow yourself, of course. It is not very hard but it is not part of Q2A, for sure.

If I were you, I'd create a plugin with a page module and link the registration to that page with the custom flow (which of course, it has to be written). Then just follow steps 3 and 4 above but rather than an empty string, I'd use the URL of the custom register page. Any other approach will be considerably more complicated
by
What if I alter the register page to make sure that the right parameter (key) is passed?  It doesn't need to be "bullet proof", just block the majority of users.  Like maybe the current date in seconds plus some number, that I then check in register.php.
by
That would be bullet proof. You'll have to edit qa-include/pages/register.php to display the "key" options  the user will choose from and be able to submit the selected key, as well as checking if key is present an valid after form submission, which is checked in line 72 of that file
by
In register.php, line 32, the comment says:

   //    Check we're not using single-sign on integration, that we're not logged in, and we're not blocked.  

What does "blocked" mean?  Could I use it to accomplish my purposes?
by
You can block a user while editing a user as an admin. It could also be blocked because the user has exceeded the spam limits set in the admin/spam section. I don't think that's going to work for you
by
I see.  Do you have time to write a code snippet for what I need per your earlier comment? You'd be enabling q2a to be used for massive healing on the planet, a sister site to www.AllWhole.com, which is not up yet in video format, but you can rapidly see it's extraordinarily advanced.  It's worth quickly checking.
by
edited by
See, as Family "comes up to speed", they're going to be helping each other get rid of all lack, loss, confusion, disease, hatred, pain, etc etc on AllHelpAll.rocks .  So before any can go there, and "give it their best thinking" (disconnected), instead of coming from Love (connected), which knows and solves, they need to get "reconnected inside".   So your assistance, though you may think it is small, IS HIGHLY IMPORTANT.  Consider all the daily suffering you're helping to alleviate the sooner all this is done.  So please "take the best" of what you read and help speed things up ... not as folks often do ... slow things down, even when the change is positive.  See, folks don't typically like change, even when they see they just got a gold-mine.  This is a gold-mine for all, so please take the best you presently can and use your talents to bless everyone; you'll forever see that contribution across time/space, everything Love extends is "eternal".  So please do that work for Family, or think of it as a good cause you are supporting.  There is even opportunity to work with me directly if you like -- some beautiful TECHNICAL openings, part time or fulltime.  But please lets just take one step at a time, as soon as possible, in Love, to alleviate suffering. (oh, maybe the parameter is passed on a post, if easier, avoid time-uniqueness).
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
...