on row, added display none in page css * #cipf_prof_paiement_reussi -> on row * #cipf_prof_paiement_echoue -> on row * */ function show_prof_paiement_messages_CIPF($user_id) { PLGNTLS_class::debug_infos(); $acf_prof_is_activ = PLGNTLS_class::ACF_PROF_IS_ACTIV; $acf_payment_status = PLGNTLS_class::ACF_CARD_PAYMENT_STATE; $acf_id = 'user_' . $user_id; /* * if prof is inactive, do nothing more * */ $is_activ = get_field($acf_prof_is_activ['_name'], $acf_id); if (is_null($is_activ)) return; if (empty($is_activ)) return; if ($is_activ === $acf_prof_is_activ['activ']) return; $cipf_prof_payement = new PLGNTLS_class(); $payement_status = get_field($acf_payment_status['_name'], $acf_id); if ($payement_status === $acf_payment_status['success']) { $cipf_prof_payement->add_to_front(array( array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_reussi {display: block;}' ) )); } else if ($payement_status === $acf_payment_status['failure']) { $cipf_prof_payement->add_to_front(array( array( 'css' => '.cipf_prof_paiement_message#cipf_prof_paiement_echoue {display: block;}' ) )); } update_field($acf_payment_status['_name'], $acf_payment_status['nothing'], $acf_id); } /* * series of check to do before printing a prof author page * */ function check_prof_page_CIPF() { PLGNTLS_class::debug_infos(); // is an author page if (!is_author()) return; // the way to find the id of the author of an author_page $author_id = get_queried_object_id(); handle_prof_is_activ_CIPF($author_id); show_prof_paiement_messages_CIPF($author_id); } add_action('template_redirect', 'check_prof_page_CIPF', 11); ?>