67 lines
889 B
PHP
67 lines
889 B
PHP
<?php
|
|
|
|
/*
|
|
* it means someone outside wp is accessing the file, in this case kill it.
|
|
*/
|
|
if (!defined('ABSPATH')) {
|
|
die('You can not access this file!');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
* check if partner can access the form to create a new page
|
|
*
|
|
*/
|
|
function partner_form_creation_page_CIPF() {
|
|
Plgntls::debug_infos(2);
|
|
$role_partner = Cipf::ROLE_PARTNER;
|
|
$slug_partner_create_page = Cipf::SLUG_PARTNER_CREATE_PAGE;
|
|
|
|
/*
|
|
* only for the partner form creation page
|
|
*
|
|
*/
|
|
if (!is_page($slug_partner_create_page)) {
|
|
return;
|
|
}
|
|
Plgntls::debug_infos();
|
|
|
|
/*
|
|
* redirect anyone that is not a partner
|
|
*
|
|
*/
|
|
if (!is_user_logged_in()) {
|
|
redirect_home_CIPF();
|
|
}
|
|
if (!current_user_can($role_partner)) {
|
|
redirect_home_CIPF();
|
|
}
|
|
|
|
/*
|
|
* if a partner already has a page, redirect it
|
|
*
|
|
*/
|
|
redirection_profil_CIPF();
|
|
}
|
|
add_action('template_redirect', 'partner_form_creation_page_CIPF');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|