79 lines
1.5 KiB
PHP
79 lines
1.5 KiB
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!');
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* prevent users to fill the renew form if
|
|
* they are not prof and logged in,
|
|
* and if there card is not in renewable state
|
|
* except admins and editor
|
|
*
|
|
*/
|
|
function renew_page_restrictions_CIPF(){
|
|
$slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
|
|
if (!is_page($slug_renew_card))
|
|
return;
|
|
|
|
if (!is_user_logged_in()) {
|
|
wp_redirect($base_url, 301);
|
|
}
|
|
|
|
$base_url = home_url();
|
|
$current_user_id = get_current_user_id();
|
|
/*
|
|
if (current_user_can('professeur__professeure')) {
|
|
$user_page = get_author_posts_url($current_user_id);
|
|
wp_redirect($user_page, 301);
|
|
}
|
|
else if (current_user_can('partenaire')) {
|
|
$args = array(
|
|
'post_type' => 'post',
|
|
'author' => $current_user_id,
|
|
'posts_per_page' => 1,
|
|
);
|
|
$posts = get_posts($args);
|
|
if (empty($posts))
|
|
$redirect_url = $base_url;
|
|
else {
|
|
$query = reset($posts);
|
|
$post_id = $query->ID;
|
|
$redirect_url = get_permalink($query->ID);
|
|
}
|
|
wp_redirect($redirect_url, 301);
|
|
}
|
|
exit;
|
|
*/
|
|
}
|
|
add_action('template_redirect', 'renew_page_restrictions_CIPF');
|
|
|
|
|
|
|
|
function renew_page_filter_message_CIPF(){
|
|
$slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD;
|
|
if (!is_page($slug_renew_card))
|
|
return;
|
|
|
|
$cipf_renew = new PLGNTLS_class();
|
|
$cipf_prof_payement->add_to_front(array(
|
|
array( 'css' => '#cipf_prof_paiement_reussi {display: block;}' )
|
|
));
|
|
}
|
|
add_action('wp_enqueue_scripts', 'renew_page_filter_message_CIPF');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|