You will need to create an event plugin. You can achieve desired processing by fetching the "u_logout" event in your plugin.
Implementation procedure:
1. Create new page
Go to "Admin" > "Pages" > "Add Page".
Example of settings:
- Name of page: "Logout message"
- Position: "No link"
- Visible for: "Anybody"
- Heading to display at top of page: "Thank you!"
- Content: Enter arbitrary HTML codes
2. Create event plugin.
2.1 Create "my-event-handler" folder under qa-plugin/.
2.2 Make plugin files under my-event-handler folder.
metadata.json
{
"name": "My Event Handler",
"description": "Custom event handling",
"version": "1.0",
"date": "2017-04-14",
"author": "PowerQA",
"author_uri": "http://www.powerqa.org",
"license": "GPLv2",
"min_q2a": "1.5"
}
qa-plugin.php
<?php
/*
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-plugin/my-event-handler/qa-plugin.php
Description: Initiates My Event Handler plugin
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
More about this license: http://www.question2answer.org/license.php
*/
/*
Plugin Name: My Event Handler
Plugin URI:
Plugin Description: Custom event handling
Plugin Version: 1.0
Plugin Date: 2017-04-14
Plugin Author: PowerQA
Plugin Author URI: http://www.powerqa.org/
Plugin License: GPLv2
Plugin Minimum Question2Answer Version: 1.5
Plugin Update Check URI:
*/
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
qa_register_plugin_module('event', 'qa-my-event-handler.php', 'qa_my_event_handler', 'My Event Handler');
qa-my-event-handler.php
<?php
/*
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
File: qa-plugin/my-event-handler/qa-event-logger.php
Description: Event module class for my event handler plugin
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
More about this license: http://www.question2answer.org/license.php
*/
class qa_my_event_handler {
public function admin_form(&$qa_content) {
$saved=false;
if (qa_clicked('meh_save_button')) {
qa_opt('meh_redirect_url_when_logout', qa_post_text('meh_redirect_url_when_logout_field'));
$saved=true;
}
$url=qa_opt('meh_redirect_url_when_logout');
$error=null;
//if (!strlen($url))
// $error='Please set relative or absolute URL.';
return array(
'ok' => ($saved && !isset($error)) ? 'Event handler settings saved' : null,
'fields' => array(
array(
'id' => 'meh_redirect_url_when_logout',
'label' => 'When users logout, they will be redirected to this page - Relative or absolute URL:',
'value' => qa_html($url),
'tags' => 'name="meh_redirect_url_when_logout_field"',
'error' => qa_html($error),
),
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'name="meh_save_button"',
),
),
);
}
public function process_event($event, $userid, $handle, $cookieid, $params) {
switch($event) {
case 'u_logout':
$this->u_logout($event, $userid, $handle, $cookieid, $params);
break;
default:
break;
}
}
private function u_logout($event, $userid, $handle, $cookieid, $params) {
$redirectpath = qa_opt('meh_redirect_url_when_logout');
if(!empty($redirectpath))
qa_redirect_raw($redirectpath);
}
}
3. Settings
- Go to "Admin" > "Plugins" > "My Event Handler" > "Settings"
- Set "Redirect path" option. It is OK either relative or absolute URL.
Note
Redirected page does not have to be pages in Q2A. It is OK at other sites (domains).