Support

Account

Home Forums ACF PRO Show frontend form only in frontend

Solved

Show frontend form only in frontend

  • Hi there,

    I am currently testing around with Frontend fields, because I will be needing them for a future project. My version is Advanced Custom Fields Pro 5.1.3

    I am using a basic WordPress Installation with the Twenty Eleven theme. Installed Plugins are: Profile Builder and ACF.

    Now my Frontend fields work nicely: Users are able to register and each user is able to fill out their individual form and also change the data later on.
    But the forms also appear in the Backend, everywhere…

    If I make the form only display on a certain page, the Frontend version doesn’t show anymore. Only the submit button is visible.

    Here are the fields with the conditionals (resulting in them being displayed everywhere) : http://screencast.com/t/ESCDq4TtTd2
    Here is the resulting (correct) Frontend display: http://screencast.com/t/xWBXMn0qd0

    And here are the altered conditionals (for only displaying on the page “ACF Test”): http://screencast.com/t/o4ycfO7J
    Here is the resulting Frontend display: http://screencast.com/t/j1QVIujheB

    How can I hide the fields in the Backend (or at least only have them display on the page “ACF Test”), so that they stay in the Frontend?

    I’ve activated
    define(‘WP_DEBUG’, true);
    define(‘WP_DEBUG_LOG’, true);
    define(‘WP_DEBUG_DISPLAY’, true);
    but no logs are created and no errors show up…

    I would greatly appreciate your support. I hope the German WordPress isn’t too troublesome. If it is, please tell me and I will try again with an english version.

    Here is my code for the page template:

    <?php
    /**
    * Template name: ACF Test
     * Template for displaying all pages
     *
     * This is the template that displays all pages by default.
     * Please note that this is the WordPress construct of pages
     * and that other 'pages' on your WordPress site will use a
     * different template.
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
     
    acf_form_head();
    get_header(); ?>
    
    		<div id="primary">
    			<div id="content" role="main">
    				
    				<?php
    					$user_id = get_current_user_id();
    					echo "User ID: ".$user_id;	
    					
    					$args = array(
    						'post_id' => 'user_'.$user_id,
    						'field_groups' => array(), // this will find the field groups for this post (post ID's of the acf post objects)
    						'form' => true, // set this to false to prevent the <form> tag from being created
    						'form_attributes' => array( // attributes will be added to the form element
    							'id' => 'post',
    							'class' => '',
    							'action' => '',
    							'method' => 'post',
    						),
    						'return' => add_query_arg( 'updated', 'true', get_permalink() ), // return url
    						'html_before_fields' => '', // html inside form before fields
    						'html_after_fields' => '', // html inside form after fields
    						'submit_value' => 'Update', // value for submit field
    						'updated_message' => 'Post updated.', // default updated message. Can be false to show no message
    					);
    				?>
    				
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php acf_form($args); ?>
    
    				<?php endwhile; // end of the loop. ?>
    
    				
    			</div><!-- #content -->
    		</div><!-- #primary -->
    
    <?php get_footer(); ?>
  • Hi @Philex

    The field group location rules you have selected will cause the field group to show up everywhere indeed.

    Because the field group is for editing a user, I suggest that you use the location rules which apply to editing a user, not ‘User Role’ (which is for editing anything).

    If this prevents the form from working on your front end, you can simply make use of the 'field_groups' => array(), value and manually add in the field group ID’s

    Cheers
    E

  • Thank you very much!

  • Is it possible to have a multi step form in front end to create a custom post with ACF?

  • Is it possible to apply conditional login if the form is being displayed on the front end (as opposed to the user admin page).

    Essentially I need to change the Information field text depending on whether front end or backend (i.e. message to admin or message to user)

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Show frontend form only in frontend’ is closed to new replies.