- updated states to work for user_id and post_id
- added states for partner page state publish-draft
This commit is contained in:
66
plugins/cipf_plugin/php/partners_form.php
Normal file
66
plugins/cipf_plugin/php/partners_form.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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 = Plgntls::ROLE_PARTNER;
|
||||
$slug_partner_create_page = Plgntls::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');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user