Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1394431
    Lyser
    Participant

    Hello,
    I would like to know how to do (if it’s possible to do that with ACF) :

    Having a field in frontend that user could fill themselves with their names and having their names displayed on the same page after.

    (It would be for a inscription page for a event)

    #1394812
    Rad
    Moderator

    Hi there,

    Thanks for posting in.

    Same as you did on your other thread, you’ll have to edit the main template. Example, the wp-index.php if it’s blog page, and content-page.php if it’s a page.

    Then follow this https://www.advancedcustomfields.com/resources/create-a-front-end-form/

    And then, you’ll have to wrap your code within is_front_page() condition to make sure it’s displayed in home page only, those templates can be used anywhere. Example:

    <?php if( is_front_page() ) :?>
    <?php acf_form_head(); ?>
    .....
    <?php acf_form(); ?>
    .....
    <?php endif; ?>

    Hope this helps.

    #1395128
    Lyser
    Participant

    Ok thx, i don’t know why all the fields are now displayed in front page, and i should have precised something : There will be a max number of people who can register for a event, that number is precised by the “places” field and each time a player enter his name, (Each names are displayed next to others) that number must decrease by one. When number 0 is reached, the entering name field should deasepear.

    1) How to create a link between the decreasing by 1 place field and the entering name field (And make it no display when 0 is reached) ?

    2) You can see that all fields are now displayed, only the entering name should be displayed in frontend, not the others who should be visible only in backoffice for admin.

    3) Is it possible to automatically add a different type of featured image in relation to what is chosen in the destination select field ? (it’s for making the things easier for the future admin instead choosing each time the right featured image among enormously), could this work for catégory too ?

    the result : http://www.lyser.fr/testwp/

    my buggy code :

    <?php
    
    // =============================================================================
    // VIEWS/INTEGRITY/CONTENT.PHP
    // -----------------------------------------------------------------------------
    // Standard post output for Integrity.
    // =============================================================================
    
    ?>
    
    <?php acf_form_head(); ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
      <div class="entry-featured">
        <?php x_featured_image(); ?>
      </div>
      <div class="entry-wrap">
        <?php x_get_view( 'integrity', '_content', 'post-header' ); ?>
        <br/>
              <?php
              // =============================================================================
              // Code for fields in backoffice ?>
              
              <?php $evenement = get_field( 'evenement' ); ?>
              <span style="color:#edeeb5; font-weight:700">&Eacute;venement :</span> <?php echo $evenement; ?><br/>
    
    	  <?php if ($evenement=='PVP') :?>
    	  <span style="color:#edeeb5; font-weight:700">Date et heure :</span> <?php the_field('date_et_heure'); ?><br/>
              <span style="color:#edeeb5; font-weight:700">Places disponibles :</span> <?php the_field('places'); ?><br/>
    	  <?php endif;?>
    
    	  <?php if ($evenement=='PVE') :?>          
              <span style="color:#edeeb5; font-weight:700">Destination :</span> <?php the_field('destination'); ?><br/>
    	  <span style="color:#edeeb5; font-weight:700">Date et heure :</span> <?php the_field('date_et_heure'); ?><br/>
              <span style="color:#edeeb5; font-weight:700">Places disponibles :</span> <?php the_field('places'); ?><br/>
    	  <?php endif;?>
              
              <?php
              // Code for fields in backoffice END
              // =============================================================================?>
              
              <?php
              // =============================================================================
              // Code for name field dispalyed in frontend ?>
              
              <?php if( is_front_page() ) :?>
              <?php acf_form_head(); ?>          
               <p>Noms des participants :</span> <?php the_field('nom'); ?></p>           
              <?php acf_form(); ?>          
              <?php endif; ?>
              
              <?php
              // Code for name field dispalyed in frontend END
    	  // =============================================================================?>
            
              <?php x_get_view( 'global', '_content' ); ?>
              
      </div>
      <?php x_get_view( 'integrity', '_content', 'post-footer' ); ?>
    </article>
    #1395129
    Lyser
    Participant
    This reply has been marked as private.
    #1395619
    Rad
    Moderator

    Hi there,

    1. I’m not sure if I understand it correctly, would you mind providing mote details 🙂

    2. Maybe it’s not possible through name? ACF is for custom fields and each custom field is attached to POST ID. Perhaps what you need is really the actual form submission. It will only display and update the post meta of current post (custom fields). Updating it will overwrite the previous data since it doesn’t add like new entry. How about event plugin?

    3. It’s not possible, just like custom field, everything on that post is attached to POST ID which is unique.

    Thanks!

    #1396923
    Lyser
    Participant

    Okay perhaps ACF is not the right addon for what i need, thx for you help anyway.

    #1397315
    Paul R
    Moderator

    You’re welcome! 🙂

  • <script> jQuery(function($){ $("#no-reply-1394431 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>