Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
in Q2A Core by
edited by

I have a custom plugin, for which users need to be logged in to use. I've added this in the process_request function:

$qa_content['error'] = 'Please <a href="' . $this->urltoroot . 'login?to=">log in</a> or <a href="' . $this->urltoroot . 'register?to=">register</a> to vote.';

Is there a better way to do this, e.g. through a Q2A function?

1 Answer

0 votes

You can use qa_insert_login_links(...) from qa-app-format.php which automatically inserts the necessary links as substitutes for ^1...^6 in the string it is passed (see function definition for the full mapping). You can also pass it a page that should be returned to after the user has logged in or registered.