Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This core hook will allows to throw 404 error if user is trying to direct access the page which menu item is hidden (not active) in Admin > pages
<?php
/*
* hook: 404 for non visible menu
*
* hook by: Q2A Market
* hook type: core
* author: Jatin Soni
* url: http://www.q2amarket.com
* version: 1.00
*
* Description:
* This core hook will allows to throw 404 error
* if user is trying to direct access the page
* which menu item is hidden (not active)
*
* usage:
* for users page - Place below code into qa-include/qa-page-users.php
* after $qa_content=qa_content_prepare();
* same way you can throw 404 for other pages
*
* Disclaimer:
* 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.
*/
if(!array_key_exists('user', $qa_content['navigation']['main'])){
header('HTTP/1.0 404 Not Found');
qa_set_template('not-found');
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('main/page_not_found');
$qa_content['suggest_next']=qa_html_suggest_qs_tags(qa_using_tags());
return $qa_content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment