Skip to content

Instantly share code, notes, and snippets.

<?php
$current_user = wp_get_current_user();
acf_enqueue_scripts();
get_header();
?>
<?php if(have_posts()): ?>
<?php while(have_posts()): the_post(); ?>
<div class="col-md-12">
/**
* ACF Form: Prevent default form submit
*/
jQuery(document).on('submit', '.acf-form', function(e) {
e.preventDefault();
});
/**
* ACF Form: Init
*/
.acf-form.acf-form-ajax .acf-error-message{
display:none;
}
.acf-form.acf-form-ajax .error.text-danger.small p{
margin:0;
margin-top:5px;
}
.acf-form.acf-form-ajax [data-name="remember_me"] ul{
<?php
add_action('template_redirect', 'hwk_acf_form_redirect');
function hwk_acf_form_redirect(){
// Logged in
if(is_user_logged_in() && (is_page('connexion') || is_page('mot-de-passe-oublie') || is_page('inscription')))
wp_redirect(home_url('mon-compte'));
// Not logged in
<?php
/**
* ACF Form Account: Register Form
*/
acf_register_form(array(
'id' => 'hwk_ajax_acf_account',
'post_id' => 'hwk_ajax_acf_account',
'form_attributes' => array(
'class' => 'acf-form acf-form-ajax',
[
{
"key": "group_5aacfcf20773c",
"title": "Connexion",
"fields": [
{
"key": "field_5aacfcf6b09b7",
"label": "Login",
"name": "login",
"type": "text",
<?php
add_action('wp_ajax_hwk_ajax_template', 'hwk_ajax_template');
add_action('wp_ajax_nopriv_hwk_ajax_template', 'hwk_ajax_template');
function hwk_ajax_template($id = false){
$configs = apply_filters('hwk_ajax_configs', $configs);
if(empty($configs))
return;
$html = hwk_ajax_config($configs, $id);
<?php
add_filter('hwk_ajax_configs', 'hwk_ajax_declare_config');
function hwk_ajax_declare_config($config){
$config[] = array(
'id' => 'hwk_ajax_heavy_query', // L'ID de référence de la configuration
'template' => 'templates/modules/module-heavy', // Path d'affichage du fichier qui effectue le traitement lourd
'cache' => 'templates/modules/cache/module-heavy', // path du fichier du cache HTML
'interval' => 900, // Intervalle de mise à jour du module
'flush' => get_the_ID(), // Flush du cache global à chaque intervalle? true|false|post_id
jQuery(document).ready(function($){
// Vérification si un container de module existe
if($('[data-hwk-ajax-action-id]').length){
// Traiter chaque module indépendamment
$('[data-hwk-ajax-action-id]').each(function(){
// Variables générales
var $this = $(this),
<?php
// Vérification que notre fichier est bien appelé via notre système
if(!$args = get_query_var('hwk_ajax_data'))
return;
// Data disponible:
// $args['id']
// $args['template']
// $args['cache']