roles)) return; /* * if prof, check card state * if cannot renew, redirect * if (current_user_can($role_prof)) { $can_renew = get_field($acf_prof_can_renew['_name'], $acf_id); if ($can_renew === false) { $redirect_url = home_url() . '/' . $slug_page_redirection; wp_redirect($redirect_url, 301); exit; } } */ /* * if prof can renew its card, reset some form fields before * */ reset_some_fields_CIPF(); } add_action('template_redirect', 'renew_page_restrictions_CIPF'); /* * on the renew card page for prof * output the right message, depending of the status of the card * 'renouveler' or 'commander' * * #cipf_prof_carte_commande -> default display: block; * #cipf_prof_carte_renouvellement -> default display: none; * */ function renew_page_filter_message_CIPF(){ PLGNTLS_class::debug_infos(); $slug_renew_card = PLGNTLS_class::SLUG_RENEW_CARD; $acf_card_state = PLGNTLS_class::ACF_CARD_STATE; if (!is_page($slug_renew_card)) return; $user_id = get_current_user_id(); $acf_id = 'user_'.$user_id; $cipf_renew = new PLGNTLS_class(); $card_state = get_field($acf_card_state['_name'], $acf_id); if ($card_state === 'Renouvellement') { $cipf_renew->add_to_front(array( array( 'css' => 'div#cipf_prof_carte_renouvellement {display: block;}' ), array( 'css' => 'div#cipf_prof_carte_commande {display: none;}' ), )); } } add_action('wp_enqueue_scripts', 'renew_page_filter_message_CIPF'); ?>