Support

Account

Home Forums Search Search Results for '%s'

Search Results for '%s'

topic

  • Solved

    Allow specific fields from repeater field on frontend form

    Is it possible to have some specific repeater fields to display on frontend form. for example look at the “fields” parameter in below example.

    $options = array(
    	'field_groups' => ['group_602a592cf1805'],
    	'fields' => [
    			'my_name', //normal ACF field, (this works!)
    			'test_repeater_field' => ['hello'], //allowing only specific field with in a repeater field, (Not working)
    		],
    	'form_attributes' => array(
    		'method' => 'POST',
    		'action' => admin_url("admin-post.php"),
    	),
    	'html_before_fields' => sprintf(
    		'<input type="hidden" name="action" value="save_user_fields_form">
        <input type="hidden" name="user_id" value="user_%s">',
    		$user->ID
    	),
    	'post_id' => "user_{$user->ID}",
    	'form' => true,
    	'html_submit_button' => '<button type="submit" class="button margin-top-20 margin-bottom-20" value="Update Profile">' . __('Submit', 'text-domain') . '</button>',
    );
    
    acf_form($options);
  • Unread

    Using the Google Maps field to output segments of an address

    The documentation for the Google Map field demonstrates a really nice way to render addresses using the address entered into the field.

    <?php 
    $location = get_field('location');
    if( $location ) {
    
        // Loop over segments and construct HTML.
        $address = '';
        foreach( array('street_number', 'street_name', 'city', 'state', 'post_code', 'country') as $i => $k ) {
            if( isset( $location[ $k ] ) ) {
                $address .= sprintf( '<span class="segment-%s">%s</span>, ', $k, $location[ $k ] );
            }
        }
    
        // Trim trailing comma.
        $address = trim( $address, ', ' );
    
        // Display HTML.
        echo '<p>' . $address . '.</p>';
    }

    For my project I am working with small towns in the UK so city, state and country are not relevant. Instead, I would like to use postal_town and administrative_area_level_2 in place of these which should render the town and county respectively. So for the foreach I have

    foreach( array( 'street_number', 'street_name', 'postal_town', 'administrative_area_level_2', 'post_code' ) as $i => $k ) { ... }

    I had assumed that this would return: number, street, town, county, post-code. But the postal_town and administrative_area_level_2 both return nothing.

    Printing the array keys using <?php print_r(array_keys($location)); ?> appears to show only a limited set of options.

    I could as a compromise just use <?php echo $location['address']; ?> but this gives a slightly different version of the address (Business name, street, town, country), but it’s not quite what I’m after.

    Does anyone know how would I go about getting my chosen values to render to the front end without having to resort to a separate address input field?

  • Solving

    Acf form does not make posts in cpt

    Hello.
    I have registered a post type and i want to have posts on it with an acf form.
    The field group contains only one field. The field is file upload field.

    The connection with post type and field works ok because i tried make post from dashboard and the field is on the editor of post type.

    When i click the submit button the form works ok but there is not a post in my custom post type.

    What’s the problem?

    I send you the custom code if you want to help.
    Thank you.

    <?php acf_form_head();
    get_header();
    ?>
    <div class="container">
    <?php
      $settings = array(
        'id' => 'photos_form',
        'field_groups' => array("group_6025117548b3f"),
        'fields' => false,
        'submit_value' => __("Submit", 'acf'),
        'label_placement' => 'top',
        'html_submit_button' => '<input type="submit" id="submitbtn" class="acf-button button primary_btn" value="%s" />',
        'html_submit_spinner' => '<span class="acf-spinner"></span>',
        'updated_message' => '',
        'html_after_fields' => '',
    );
    acf_form($settings);?>
    </div>
    <?php get_footer(); ?>
  • Helping

    Don't recive taxonomy title

    Hi, i have form to add new taxonomy and i also need template with form for editing this taxonomy so have for editing taxonomy next form but problem is that i get all value for custom field but for title of taxonomy i didnt get.

    <?php acf_form(array(
        'post_id' => $_GET["post"],
        'post_title'	=> true,
        'field_groups' => array(
            'group_5f475552ca375'
         ),
        'submit_value'		=> 'Shrani',
        'html_submit_button'	=> '<input type="submit" class="acf-button btn btn-primary" value="%s" />',
        'uploader' => 'wp',
        )); 
    ?>

    $_GET[“post”] i get from url parameter and the post title input is vissible but it is empty

  • Solved

    create new taxonomy with acf form not new post

    Hi i want to save a new taxonomy, but i cant get the form to frontend.
    Custom field are sucess visible in backend but on frontend i cant see, i think becuse i dont have right code. My custom taxonomy name is “narocilnice” and code is:

    <?php acf_form(array(
        'id' => 'acf-form',
        'post_id' => true,
        'post_title'	=> true,
        'new_post'		=> array(
            'tax_name'		=> 'narocilnice',
        ),
        'submit_value'		=> 'Shrani',
        'html_submit_button'	=> '<input type="submit" class="acf-button btn btn-primary" value="%s" />',
        'uploader' => 'wp'
        )); 
    ?>

    On this picture printscreen you can see that i get on backend custom field but on frontend i can’t. So i need add new taxonomy to custom taxonomy name “narocilnice” not new post to custom post_type.

    Can someone tell me what is wrong?

  • Unread

    get_field_object not working with restrict_manage_posts action

    I am using the action restrict_manage_posts to create a custom filter for my posts:

    add_action( 'restrict_manage_posts', '_s_custom_filter' );
    
    function kiewit_locations_custom_filter($post_type){
    	
    	if ($post_type === 'custom_post_type'){
    		
    		$args = array(
    			'post_type'  => 'custom_post_type',
    			'parent'     => 0
    		);
    
    		$items = get_pages( $args );
            ?>
            <select id="filter_by_custom_post_type" name="filter_by_custom_post_type">
            <option value=""><?php _e('All Custom Posts', '_s'); ?></option>
            <?php
                $current_v = isset($_GET['filter_by_custom_post_type']) ? $_GET['filter_by_custom_post_type'] : '';
                foreach( $items as $item ) {
                    printf
                        (
                            '<option value="%s"%s>%s</option>',
                            $item->post_name,
                            $item->post_name == $current_v? ' selected="selected"':'',
                            $item->post_title
                        );
                    }
            ?>
            </select>
            <?php
        }
    }

    I also have custom columns set up on my custom_post_type to display selected meta data from a select field and try to display that data using get_field_object('custom_select_information');, however, that always returns false, even if I use the field key.

    Any ideas how to get that custom_select_information to display when filtering my posts?

  • Solving

    Sort Custom Post Type by Taxonomy.

    Hi
    I have a query I would like to resolve.

    The scenario is as follows:
    I have a custom post type called Auction.

    Auctions have an acf in relation to a custom post type product.
    Those products can be assigned taxonomies.

    My question is how to sort those products by taxonomy when I’m on the single-auction.php page.

    Following the documentation I can show all the products of an auction, but I would like to sort those products by their taxonomy.

    An image to clarify what I want to get :

    A brief explanation:

    Taxonomy Term A

    Product 1
    Product 2

    Taxonomy Term B

    Product 3
    Product 4
    Order custom post type by taxonomy

    My code :

    $featured_posts = get_field(‘products_in_this_auction’);
    (Note: get_field(‘products_in_this_auction’) is a Post Object)
    This is a post object and contains the ids of the products that are linked to the auction.

    But my problem is how to get those products sorted by taxonomy.
    I guess I have to use tax_query for my
    query.

    I have an old code that shows me all the custom post type products ordered by their taxonomy, as seen in the image, but what I need is to show only the custom post type products that depend on the current auction.

    I know those custom post type are in $featured_posts = get_field(‘products_in_this_auction’); but I don’t know how to get them.

    My code, something old-fashioned, is the following.

     $categories = get_terms('type_produc', 'orderby=count&order=DESC&hide_empty=1');
                          foreach( $categories as $category ): 
                          ?>
                          <h3 class="title_pru"><?php echo $category->name; // Prints the cat/taxonomy group title ?></h3>
                          <?php
                          $posts = get_posts(array(
                          'post_type' => 'myproduct',
                          'taxonomy' => $category->taxonomy,
                          'term' => $category->slug,
                          'nopaging' => true,
                          ));
                          foreach($posts as $post): 
                          setup_postdata($post); 
                          ?>
                         
                          <div id="post-<?php the_ID(); ?>">
                         
                        
                        <?php  the_title( sprintf( '<p class="title_pru"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></p>' ); ?>
                         
                       
                         
                          </div><!-- #post-## --> 
                          <?php endforeach; ?>
                         
                         <?php endforeach; ?>

    This code shows the result of the image, but it doesn’t work for me.

    I hope someone can help.
    Thank you very much.

  • Solving

    InnerBlocks + Slick slider

    Hi,
    I’m trying to make hero section where one column has slick slider (repeater field with images) and second one with innerBlocks.

    Problem:
    When I edit slider in any way (change order of sub_fields/ add new/ remove one) block preview slick slider can’t re-initialize.

    If I comment out ‘jsx’ or change to ‘false’ – slider is working as expect.

    In demo version i just simplify everything and copy-paste from code examples – same effect:

    functions.php

    add_action('acf/init', 'my_acf_init_blocks');
    function my_acf_init_blocks() {
    
        // Check function exists.
        if( function_exists('acf_register_block_type') ) {
    
            // Register a restricted block.
            acf_register_block_type(array(
                'name'              => 'test',
                'title'             => 'Test',
                'description'       => 'A test content block.',
                'category'          => 'formatting',
                'mode'              => 'preview',
                'supports'          => array(
                    'align' => true,
                    'mode' => false,
                    'jsx' => true
                ),
                'enqueue_assets' 	=> function(){
                  $theme = wp_get_theme( );
                  $ver = $theme->version;
                  wp_enqueue_style( 'slick', 'https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.css', array(), $ver );
                  wp_enqueue_style( 'slick-theme', 'https://cdn.jsdelivr.net/npm/[email protected]/slick/slick-theme.css', array(), $ver);
                  wp_enqueue_script( 'slick', 'https://cdn.jsdelivr.net/npm/[email protected]/slick/slick.min.js', array('jquery'), $ver, true );
                  wp_enqueue_style( 'test-css', get_template_directory_uri() . '/test.css', array(''), $ver, 'all' );
                  wp_enqueue_script( 'test-js', get_template_directory_uri() . '/test.js', array('jquery'), $ver, true );
                },
                'render_template' => 'test.php',
            ));
        }
    }

    test.php

    $classes = '';
    if( !empty($block['className']) ) {
        $classes .= sprintf( ' %s', $block['className'] );
    }
    if( !empty($block['align']) ) {
        $classes .= sprintf( ' align%s', $block['align'] );
    } ?>
    
    <div class="test <?php echo esc_attr($classes); ?>">
        <div class="test-col">
        	<InnerBlocks  />
        </div>
        <div class="test-col slider">
    			<?php if( have_rows('slides') ): ?>
    				<div class="slides">
    					<?php while( have_rows('slides') ): the_row();
    						$image = get_sub_field('image');
    						?>
    						<div>
    							<?php echo wp_get_attachment_image( $image['id'], 'full' ); ?>
    						</div>
    					<?php endwhile; ?>
    				</div>
    			<?php else: ?>
    				<p>Please add some slides.</p>
    			<?php endif; ?>
        </div>
    </div>

    test.js

    (function($){
        var initializeBlock = function( $block ) {
            $block.find('.slides').slick({
                dots: true,
                infinite: true,
                speed: 300,
                slidesToShow: 1,
                centerMode: true,
                variableWidth: true,
                adaptiveHeight: true,
    			focusOnSelect: true
            });
        }
    
        // Initialize each block on page load (front end).
        $(document).ready(function(){
            $('.slider').each(function(){
                initializeBlock( $(this) );
            });
        });
    
        // Initialize dynamic block preview (editor).
        if( window.acf ) {
            window.acf.addAction( 'render_block_preview/type=test', initializeBlock );
        }
    
    })(jQuery);

    As alternative option from formums: test.js

    (function($){
        var initializeBlock = function( $block ) {
            function getSliderSettings() {
                dots: true,
                infinite: true,
                speed: 300,
                slidesToShow: 1,
                centerMode: true,
                variableWidth: true,
                adaptiveHeight: true,
    			      focusOnSelect: true
            }
            $block.find('.slides').slick( getSliderSettings() );
        }
    
        // Initialize each block on page load (front end).
        $(document).ready(function(){
            $('.slider').each(function(){
                initializeBlock( $(this) );
            });
        });
    
        // Initialize dynamic block preview (editor).
        if( window.acf ) {
            window.acf.addAction( 'render_block_preview/type=test', initializeBlock );
        }
    
    })(jQuery);

    I believe there’s a solution to reint slick in better wahy, but maybe it’s just bug?

  • Unread

    multiple forms in front end user account

    Hi all.

    I’m building a website that is for booking events, the e-commerce platform is woocommerce. I’ve acted an action to add a new page to the user account called family, where I want the user to be able to manage their family members and contact info.

    So far I’ve added the page, created a repeater for user where they can add a family member and fill in that members information, it saves and all works great.

    Now I’d like to add an ACF group before the repeater that has main information such as emergency contact details and next of kin, but I can’t figure out how to display two fields (the group and the repeater) within the one action and only have one save button to save the details to the users account.

    This is what I have so far that works for the repeater, but if anyone could steer me in the right direction as to how to add the group field, it’d be hugely appreciated.

    <?php
      acf_form_head();
      get_header(); 
    ?>
    
    Family
    
    <div class="family-members-form"><?php 
    
     if ( !is_user_logged_in() ){ 
     echo 'You are not logged in. <br /> <a href="' . get_permalink(31) .'">Log In &rarr;</a>';
    
     } else {
    
     $user = wp_get_current_user();
     
    
    $options = array(
      // 'field_groups' => ['group_5cbd99ef0f584'],
      'fields' => ['field_5f24194f719ca'],
      'form_attributes' => array(
        'method' => 'POST',
        'action' => admin_url("admin-post.php"),
      ),
      'html_before_fields' => sprintf(
        '<input type="hidden" name="action" value="adaptiveweb_save_profile_form">
        <input type="hidden" name="user_id" value="user_%s">',
        $user->ID
      ),
      'post_id' => "user_{$user->ID}",
      'form' => true,
      'html_submit_button' => '<button type="submit" class="acf-button button button-primary button-large" value="Update Profile">Update Profile</button>',
    );
    
    acf_form($options);
     }
    
     ?>
     
     </div>
  • Solving

    Restricted-InnerBlocks example: content doesn\'t display

    Hey guys.
    I wanted to understand the new beta features, the innerblocks. So I copied the Code from here:

    https://www.advancedcustomfields.com/blog/acf-5-9-exciting-new-features/

    but nothing is working.

    function.php
    require get_template_directory() . ‘/enqueue/enqueue_blocks.php’;

    enqueue_blocks.php

    <?php
    
    /*Test*/
    add_action('acf/init', 'my_acf_blocks_init');
    function my_acf_blocks_init() {
    
        // Check function exists.
        if( function_exists('acf_register_block_type') ) {
    
            // Register a restricted block.
            acf_register_block_type(array(
                'name'				=> 'restricted',
                'title'				=> 'Restricted',
                'description'		=> 'A restricted content block.',
                'category'			=> 'formatting',
                'mode'				=> 'preview',
                'supports'			=> array(
                    '__experimental_jsx' => true
                ),
                'render_template' => get_template_directory_uri() . '/template-parts/blocks/restricted/restricted.php',
                'enqueue_style' => get_template_directory_uri() . '/template-parts/blocks/restricted/restricted.css'
            ));
        }
    }

    restricted.php

    <?php
    /**
     * Restricted Block Template.
     *
     * @param   array $block The block settings and attributes.
     * @param   string $content The block inner HTML (empty).
     * @param   bool $is_preview True during AJAX preview.
     * @param   (int|string) $post_id The post ID this block is saved to.
     */
    
    // Create class attribute allowing for custom "className" and "align" values.
    $classes = '';
    if( !empty($block['className']) ) {
        $classes .= sprintf( ' %s', $block['className'] );
    }
    if( !empty($block['align']) ) {
        $classes .= sprintf( ' align%s', $block['align'] );
    }
    
    // Load custom field values.
    $start_date = get_field('start_date');
    $end_date = get_field('end_date');
    
    // Restrict block output (front-end only).
    if( !$is_preview ) {
        $now = time();
        if( $start_date && strtotime($start_date) > $now ) {
            echo sprintf( 'Content restricted until %s. Please check back later.
    ', $start_date );
            return;
        }
        if( $end_date && strtotime($end_date) < $now ) {
            echo sprintf( 'Content expired on %s.
    ', $end_date );
            return;
        }
    }
    
    // Define notification message shown when editing.
    if( $start_date && $end_date ) {
        $notification = sprintf( 'Content visible from %s until %s.', $start_date, $end_date );
    } elseif( $start_date ) {
        $notification = sprintf( 'Content visible from %s.', $start_date );
    } elseif( $end_date ) {
        $notification = sprintf( 'Content visible until %s.', $end_date );
    } else {
        $notification = 'Content unrestricted.';
    }
    ?>
    <?php echo var_dump($start_date);?>
    
    <div class="restricted-block <?php echo esc_attr($classes); ?>">
        Test
    
        <span class="restricted-block-notification"><?php echo esc_html( $notification ); ?></span>
        <InnerBlocks  />
    </div>

    restricted.css

    .restricted-block{
        padding: 15px;
        background-color: #0c5460;
        border: 12px solid #20c997;
    }
    
    .restricted-block-notification
    {
        background-color: #43494e;
        padding: 5px;
        float: left;
        color: white;
    }

    I checked the Path – as I saw, the restricted.css file is loading. (network analysis, 304) Also the Data-Blocks is showing up on the right side.

    But the var-dump doesnt show anything and even when I messed up the .php, there doesn’t come a fatal error. But the Path is the Same as the CSS.

    I also made sure, that I downloaded the beta-version.

    so… what i am doing wrong?

  • Unread

    Google maps marker won't save values if no address was found

    Since version 5.8.6, Google maps field won’t save custom marker locations if Google Geocoder returns “ZERO_RESULTS” as status. This happens for locations without a known address.

    searchPosition: function( lat, lng ){
    			//console.log('searchPosition', lat, lng );
    			
    			// Start Loading.
    			this.setState( 'loading' );
    			
    			// Query Geocoder.
    			var latLng = { lat: lat, lng: lng };
    			geocoder.geocode({ location: latLng }, function( results, status ){
    			    //console.log('searchPosition', arguments );
    			    
    			    // End Loading.
    			    this.setState( '' );
    			    
    			    // Status failure.
    				if( status !== 'OK' ) {
    					this.showNotice({
    						text: acf.__('Location not found: %s').replace('%s', status),
    						type: 'warning'
    					});
    
    				// Success.
    				} else {
    					var val = this.parseResult( results[0] );
    					
    					// Override lat/lng to match user defined marker location.
    					// Avoids issue where marker "snaps" to nearest result.
    					val.lat = lat;
    					val.lng = lng;
    					this.val( val );
    				}
    					
    			}.bind( this ));
    		},
  • Solved

    Custom fields blocked

    Hello community,

    I have the problem that the use of my ACF is blocked. I use a code snippet on the homepage that I found on the Internet and that fulfills its task so far. This enables the last 3 posts of a respective category to be displayed. If I now use an ACF afterwards, it is no longer displayed. Delete the snipped everything works well. I hope you can help me.

    Thank you.

    Code Snipped:

    <div class="row py-4">
    	<div class="col-md-12 mb-2">
    		<h3>Kampagne 2020</h3>
    	</div>
    	<?php
    		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    		$args = array(
    			'category_name' => 'kampagne-2020',
    			'orderby' => 'date',
    			'post_type' => 'post',
    			'posts_per_page' => 3,
    			'paged' => $paged,
    		);
    		$wp_query=new WP_Query($args);
    		if ( $wp_query->have_posts() ) :
    			while ( $wp_query->have_posts() ) : $wp_query->the_post();
    				$background = get_the_post_thumbnail_url(get_the_ID(), 'full');
    
    				$category = get_the_category();
    				$category_class = $category[0]->slug;            
    	?>
    	<div class="col-xl-4 col-lg-6 col-md-6 d-flex mb-2">
    		<div class="front-kampagne-2020">
    			<?php if ( has_post_thumbnail() ) : ?>
    				<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
    					<?php the_post_thumbnail('full', array('class' => 'img-fluid mb-2')); ?>
    				</a>
    			<?php endif; ?>
    			<?php the_title( sprintf( '<h3><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ),	'</a></h3>' ); ?>
    			<p class="excerpt"><?php echo excerpt(25); ?></p>
    			<a href="<?php the_permalink(); ?>" class="read_more"><button type="button" class="understrap-read-more-link">Weiterlesen...</button></a>
    		</div>
    	</div>
    	<?php endwhile; ?>
    		<?php wp_reset_postdata(); else: ?>
    			<h5>Es gibt keine Ergebnisse, die Ihren Suchkriterien entsprechen</h5>
    		<?php endif; ?>
    </div><!-- /Kampagne 2020 -->
  • Unread

    Front end form create term

    Hello, I’m working on a form to create (and after manage it with the values) terms from a CPT. I would like to have an front-end form to do that.
    Now, with my code, I can create a new term, but the others fields (in the group 390 : adresse, phone, etc) doesn’t accept the value. This fields are desperately empty. What can I do, what is wrong in my code. Any help is welcome ! Thanx in advance !

    <?php
    /*
     * Template Name: create illustrateur
    */
        
      function save_illustrator( $post_id ) {
        // check if this is to be a new post
        if( $post_id != 'new' )
        {
            return $post_id;
        } 
        // Create a new term
    $new_term =  $_POST['acf']['field_5ee62e83a2b4d'] // this is my field title;
        $post_id = wp_insert_term( 
            $new_term, 
            'illus',
           array(
           'adresse' => $adresse =  $_POST['acf']['field_5ead99082e3f7'] ,
        )
    );
      $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
    
        // return the new ID
        return $post_id;
    }
    add_filter('acf/pre_save_post' , 'save_illustrator' );
    
    acf_form_head(); 
    
    get_header();
    ?>
    
        
    <form id="post" class="acf-form" action="" method="post">
    
    <h4 class="form">Creation </h4>    
    
        <?php acf_form( array(
            'post_id'	=> 'new',
            'field_groups' => array(632, 390), //632 : My Title 390 My others fields (contact, adresse)
            'form' => false,
    		'post_status'	=> 'publish',
    		//'post_type'		=> 'livret',
    		'updated_message'    => 'La nouvelle ficher vient d’être créée. ',
            'html_updated_message'  => '<div id="message" class="updated"><p>%s</p></div>',
        )); ?>
    
        <div class="field">
            <input type="submit" value="Creation">
        </div>
        
    </form>
    
     
        <?php get_footer(); ?>
  • Solving

    Use data from ACF field to automatically populate another form field

    Hi everyone,
    I’m new to both ACF and WordPress, so excuse me if the question is unappropriate. I have the following situation that I don’t know how to handle.
    I have a frontend form to register users. While registering, users should define the company they work for. If the company is not already present in the database, they should add it. The company is a custom type and I handle it using ACF, which is called in a modal in the form page.
    The form depicted in the modal is made using ACF, as follows, in my add-company-form.php:

    acf_form_head();
    
    get_header();
    
    <div id="add-company-dialog" class="pr-add-company">
        <h1 class="pr-dialog-title">Add new company/institute</h1>
        <?php
    	
    	acf_form(array(
    		'post_id'		=> 'new_post',
    		'post_title'	=> true,
    		'post_content'	=> false,
    		'new_post'		=> array(
    			'post_type'		=> 'company',
    			'post_status'	=> 'publish'
    		),
    		'submit_value'	=> 'Create Company'
    	));
    	?>
    </div>

    While the main form is in my signup-form.php and is the following:

    <div class="pr-signup-page">
    
        <form class="pr-signup-form" action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="POST">
            <fieldset class="pr-signup-form__fieldset">
            <div class="pr-signup-form__field-wrap-one-trd">
                <label class="pr-signup-form__field-label" for="pr-name"><?php echo __("First name", N7_PRIMIS_TEXTDOMAIN)?>*</label>
                <input type="text" name="pr-name" required>
            </div>
            <div class="pr-signup-form__field-wrap-one-trd-last">
                <label class="pr-signup-form__field-label" for="pr-last-name"><?php echo __("Last name", N7_PRIMIS_TEXTDOMAIN)?>*</label>
                <input type="text" name="pr-last-name" required > 
            </div>
            <div class="pr-signup-form__field-wrap-one-trd">
                <label class="pr-signup-form__field-label" for="pr-inst-email"><?php echo __("Institutional email", N7_PRIMIS_TEXTDOMAIN)?>*</label>
                <input type="email" name="pr-inst-email" required>
                <span class="pr-signup-form__field-help"><?php echo __("Insert your official email account of your insitution/company", N7_PRIMIS_TEXTDOMAIN)?></span>
            </div>
            </fieldset>
            <fieldset class="pr-signup-form__fieldset">
            <div class="pr-signup-form__field-wrap-one-trd pr-signup-form__institute">
                <label class="pr-signup-form__field-label" for="pr-company"><?php echo __("Company / Institute", N7_PRIMIS_TEXTDOMAIN)?>*</label>
                <input type="hidden" name="pr-company-id" id="autocomplete-company-id">
                <input type="text" name="pr-company" id="autocomplete-company" required autocomplete="on">
            </div>
            <div class="pr-signup-form__field-wrap-one-trd-last">
                <label class="pr-signup-form__field-label" for="pr-department"><?php echo __("Department", N7_PRIMIS_TEXTDOMAIN)?></label>
                <input type="text" name="pr-department">
            </div>
            <div class="pr-signup-form__field-wrap-one-trd">
                <label class="pr-signup-form__field-label" for="pr-inst-email"><?php echo __("FAX", N7_PRIMIS_TEXTDOMAIN)?></label>
                <input type="text" name="pr-fax">
            </div>
            <div class="pr-signup-form__field-wrap-one-trd">
                <label class="pr-signup-form__field-label" for="pr-inst-email"><?php echo __("Phone", N7_PRIMIS_TEXTDOMAIN)?></label>
                <input type="tel" name="pr-tel">
            </div>
            <div class="pr-signup-form__field-wrap-one-trd">
                <label class="pr-signup-form__field-label" for="pr-inst-email"><?php echo __("Mobile Phone", N7_PRIMIS_TEXTDOMAIN)?></label>
                <input type="tel" name="pr-mobile">
            </div>   	
            <div class="pr-signup-form__field-wrap field-checkbox">
                <input type="checkbox" name="pr-condition-accepted" required value="1">
                <label class="pr-signup-form__field-label" for="pr-subscribe-nws"><?php echo sprintf( __( 'I have read the information about the <a target="_blank" href="%s">Privacy Policy</a> and I agree the use of my personal data.', 'zaki' ), get_permalink( icl_object_id( 12205, 'page' ) ) ); ?></label>
            </div>
        
    
      
            <div class="pr-signup-form__field-action-wrap  pr-signup-form__field-action-wrap-centered">
            <input type="hidden" name="action" value="pr_register_certified"> 
                <button type="submit" class="pr-btn pr-btn-green pr-signup-form__submit" value="<?php echo __("Sign Up as Certified User", N7_PRIMIS_TEXTDOMAIN) ?>">
               
                <i class="fas fa-badge-check"></i> 
                    <?php echo __("Sign Up as Certified User", N7_PRIMIS_TEXTDOMAIN) ?>
                </button>
            </div>   
    
            
            
            </fieldset>        
        </form>
    </div>
    
    <?php pr_add_partial("public/partials/n7-primis-add-company-form", array(), true); ?>

    So here is my question. Is it possible, when a user fills in the modal (hence adds a new company) to automatically populate the company field in the main form with the name of the newly added company in the ACF form?
    Any suggestion or hint would be really appreciated since I really am a beginner here.
    Many thanks,
    Giulia

  • Unread

    add acf value to product permalink woocommerce

    Hello,

    i try to add values to woocommerce product permalink.

    my code :

    //add rewrite rules 
    function product_add_rewrite_rules() {
    	global $wp_rewrite;
        
    	$wp_rewrite->add_rewrite_tag('%product%', '([^/]+)', 'product=');
    	$wp_rewrite->add_rewrite_tag('%subtitle%', '([^/]+)', 'subtitle=');
    	$wp_rewrite->add_rewrite_tag('%artiste%', '([^/]+)', 'artiste=');
    	$wp_rewrite->add_rewrite_tag('%numero_de_page%', '([^/]+)', 'numero_de_page=');
    	$wp_rewrite->add_permastruct('product', '/catalogue/%artiste%-%product%-%subtitle%-page-%numero_de_page%/', false);
        
        $wp_rewrite->flush_rules();
    }
    add_action('init', 'product_add_rewrite_rules', 10, 0);
    
    // replace the rwrite tag by the content
    function product_permalinks($permalink, $post, $leavename) {
    	$post_id = $post->ID;
    
    	if ($post->post_type == 'product') {
    		$subtitle = sanitize_title(get_field('subtitle', $post_id));
    		$artiste = get_field('artiste', $post_id);
            $artistesurname = sanitize_title($artiste->name);
    		$pagenumber = sanitize_title(get_field('numero_de_page', $post_id));
    		if ($artiste) { 
    			$permalink = str_replace('%artiste%', $artistesurname, $permalink);
    		} else {
    			$permalink = str_replace('%artiste%', 0, $permalink);
    		}
            if ($subtitle) { 
    			$permalink = str_replace('%subtitle%', $subtitle, $permalink);
    		} else {
    			$permalink = str_replace('%subtitle%', 0, $permalink);
    		}
            if ($pagenumber) { 
    			$permalink = str_replace('%numero_de_page%', $pagenumber, $permalink);
    		} else {
    			$permalink = str_replace('%numero_de_page%', 0, $permalink);
    		}
    	}
    
    	return $permalink;
    }
    add_filter('post_type_link', 'product_permalinks', 10, 3);
    

    In the backend it’s showing the change :
    permalink display in the backend

    But in frontend i get a 404. I tried on an other custom post and i get the same.
    Anyone had already the same problem ?

    Thanks in advance,

    Simon

  • Helping

    add acf value to woocommerce permalink

    Hello,

    i try to add values to woocommerce product permalink.

    my code :

    //add rewrite rules 
    function product_add_rewrite_rules() {
    	global $wp_rewrite;
        
    	$wp_rewrite->add_rewrite_tag('%product%', '([^/]+)', 'product=');
    	$wp_rewrite->add_rewrite_tag('%subtitle%', '([^/]+)', 'subtitle=');
    	$wp_rewrite->add_rewrite_tag('%artiste%', '([^/]+)', 'artiste=');
    	$wp_rewrite->add_rewrite_tag('%numero_de_page%', '([^/]+)', 'numero_de_page=');
    	$wp_rewrite->add_permastruct('product', '/catalogue/%artiste%-%product%-%subtitle%-page-%numero_de_page%/', false);
        
        $wp_rewrite->flush_rules();
    }
    add_action('init', 'product_add_rewrite_rules', 10, 0);
    
    // replace the rwrite tag by the content
    function product_permalinks($permalink, $post, $leavename) {
    	$post_id = $post->ID;
    
    	if ($post->post_type == 'product') {
    		$subtitle = sanitize_title(get_field('subtitle', $post_id));
    		$artiste = get_field('artiste', $post_id);
            $artistesurname = sanitize_title($artiste->name);
    		$pagenumber = sanitize_title(get_field('numero_de_page', $post_id));
    		if ($artiste) { 
    			$permalink = str_replace('%artiste%', $artistesurname, $permalink);
    		} else {
    			$permalink = str_replace('%artiste%', 0, $permalink);
    		}
            if ($subtitle) { 
    			$permalink = str_replace('%subtitle%', $subtitle, $permalink);
    		} else {
    			$permalink = str_replace('%subtitle%', 0, $permalink);
    		}
            if ($pagenumber) { 
    			$permalink = str_replace('%numero_de_page%', $pagenumber, $permalink);
    		} else {
    			$permalink = str_replace('%numero_de_page%', 0, $permalink);
    		}
    	}
    
    	return $permalink;
    }
    add_filter('post_type_link', 'product_permalinks', 10, 3);
    

    In the backend it’s showing the change :
    permalink display in the backend

    But in frontend i get a 404. I tried on an other custom post and i get the same.
    Anyone had already the same problem ?

    Thanks in advance,

    Simon

  • Solved

    Display field in array

    Hello I have coauthors plus and I want to show a title text from the users profile. Ive done this with Toolset Types and it worked great. But i have decided to only use ACF and I cannot get it to work. The code below is from the array i want to put my field in

    
    	$args = array(
    		'before_html' => '',
    		'href' => get_author_posts_url( $author->ID, $author->user_nicename ),
    		'rel' => 'author',
    		'title' => sprintf( __( 'Posts by %s', 'co-authors-plus' ), apply_filters( 'the_author', $author->display_name ) ),
    		'class' => 'author url fn',
    		'text' => apply_filters( 'the_author', $author->display_name ),
    		'after_html' => ', ' ,
    		'title' => get_field('title', 'user_'. $array['ID'] ) ,
    	);

    This is the part I cannot fix: ‘title’ => get_field(‘title’, ‘user_’. $array[‘ID’] ) ,. It doesnt display anything. In Types I used this: ‘title’ => types_render_usermeta( ‘title’, array(‘user_id’ => $author->ID,)) ,

    Thanks

  • Unread

    ACF Taxonomies : Get just the used Terms in a DropDown

    Hi

    I haven’t found an answer to my question yet …

    I’m looking for a solution to list “Terms” used in custom post in a dropdown (Name + Link).

    I created an ACF Taxonomy like on the screenshot below.

    From my custom post I chose the main Term (1 only) which will be displayed on my thumbnails in my list (Archive).

    I tried a loop here, I have the 10 terms used on all of my CPTs but the names and links are not displayed.

    					  <?php 
    					  	$taxonomies = get_field('thematique');
    					  	
    					  	// args
    					  	$args = array(
    					  		'numberposts' => -1,
    					  		'post_type' => 'portfolio',
    					  		'tax_query' => array(
    					  			array(
    					  				'taxonomy' => 'categoriesportfolio',
    					  				'field' => 'motscles',
    					  				'terms' => array()
    					  			),
    					  		)
    					  	);
    					  	
    					  	if( $taxonomies )
    					  	{
    					  		foreach( $taxonomies as $term )
    					  		{
    					  			$args['tax_query']['terms'][] = $term->name;
    					  			$term_list .= '<a href="' . esc_url( get_term_link( $term ) ) . '" alt="' . esc_attr( sprintf( __( 'View all post filed under %s', 'my_localization_domain' ), $term->name ) ) . '" class="dropdown-item" >' . $term->name . '</a>';
    					  		}
    
    						 echo $term_list;
    
    					  	}
    
    					  	// get results
    				  		$the_query = new WP_Query( $args );
    					  
    					  	?>

    Thanks for your help ! 🙂

  • Unread

    CPT with custom datatable insert, update

    Hello,

    I have a CPT with ACF and I have managed to get those fields to save to a custom data table.
    How can I update the same ACF values, with the same post_id, while I’m updating the CPT?
    Here is what I have done so far.
    Now how to update this?

    
    add_action('acf/save_post', 'my_acf_save_post');
      function my_acf_save_post( $post_ID ) {
                    global $wpdb;
    	        $table = $wpdb->prefix.'analiza';
                    $ime_radnika_1 = get_field('ime_radnika_1', $post_ID);
    		$data = array('post_ID'=>$post_ID,'name' => $ime_radnika_1);
    		$format = array('%d','%s');
    		$wpdb->insert($table,$data,$format);
    }
    
  • Unread

    Supply a foreach to ACF Select Field

    So I have the form bit of a WP Core Widgets class that I am working on and I’m stuck on wanting to supply a list that’s already populated to a Advanced Custom Field ‘select’ field.

    Instead of lists, how can I supply and save the drop-down results to acf_lists?

        // This is the backend of the widgets
        public function form($instance)
        {
        
            // Grab the widget ID
            $widget_id = $this->id;
        
            $acf_lists = get_field('mailchimp_list', $widget_id) ? get_field('mailchimp_list',$widget_id) : '';
            var_dump($acf_lists);
        
            // Grab the MailChimp_API getters and setters
            $api = mailchimpSF_get_api();
        
            // If there is no API, return
            if (!$api) {
                return;
            }
        
            // If there is an API Key, proceed
            if ($api) {
        
                $lists = $api->get(
                    'lists',
                    100,
                    [
                        'fields' => 'lists.id,lists.name,lists.email_type_option'
                    ]
                );
                $lists = $lists['lists'];
        
                // If there are no lists present
                if (count($lists) == 0) {
                    ?>
                    <span class='error_msg'>
                    <?php
                    echo sprintf(
                        esc_html("Uh-oh, you don't have any lists defined! Please visit %s, login, and setup a list before using this tool!"),
                        "<a href='http://www.mailchimp.com/'>MailChimp</a>"
                    );
                    ?>
                </span>
                    <?php
                } else {
                    ?>
                    <table class="mc-list-select">
                        <tr class="mc-list-row">
                            <td>
                                <select name="mc_list_id">
                                    <option value=""> &mdash; <?= 'Select A List' ?>
                                        &mdash;
                                    </option>
                                    <?php
                                    foreach ($lists as $list) {
                                        $option = get_option('mc_list_id');
                                        ?>
                                        <option value="<?= $list['id'] ?>"<?= selected($list['id'],
                                            $option); ?>><?= $list['name'] ?></option>
                                        <?php
                                    }
                                    ?>
                                </select>
                            </td>
                            <td>
                                <input type="hidden" name="mcsf_action"
                                       value="update_mc_list_id"/>
                                <input type="submit" name="Submit"
                                       value="<?= 'Update List' ?>" class="button"/>
                            </td>
                        </tr>
                    </table>
                    <?php
                }
            }
        }

    Here is what the widget looks like:

    [![enter image description here][1]][1]

    How can I supply the current foreach that I have into the $acf_lists variable? I’m able to loop through and supply it to a standard drop-down but I’m unsure how I can supply it to the ACF dropdown.

    This is my ACF Mailchimp list select field:

    [![enter image description here][2]][2]

    [1]: https://i.stack.imgur.com/M7FNX.png
    [2]: https://i.stack.imgur.com/0Xukh.png

  • Unread

    How to get field from from taxonomy of CPT?

    Hello. I have CPT – “Catalog”, and my CTP have custom taxonomy Type.
    I try to display all categories on another page and I’m used this code:

    <?php
    																		$categories = get_categories(array(
    																			'taxonomy' => 'type',
    																			'type' => 'catalog',
    																			'orderby' => 'name',
    																			'hide_empty'   => 0,
    																			'order' => 'ASC'
    																		));
    																		foreach( $categories as $category ){
    																			echo '<div class="col-12 col-md-6 col-lg-4">';
    																			echo '<div class="n-catalog-item__block">';
    																			echo '<a href="' . get_category_link( $category->term_id ) . '" class="n-catalog-item__icon"><img src="' . get_field('catalog_category_icon', $category->term_id) . '"></a>';
    																			echo '<div class="n-catalog-item__info">';
    																			echo '<div class="n-catalog-item__name"><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "Усі матеріали в категорії: %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </div> ';
    																			echo '</div>';
    																			echo '</div>';
    																			echo '</div>';
    																		}
    																	?>

    In this code I try to display my custom field:
    <img src="' . get_field('catalog_category_icon', $category->term_id) . '">

    If I do <?php var_dump($category->term_id); ?> – return “int(402)” – (402 its category ID)

    What I do wrong?

  • Solved

    acf_form failing after update

    Hello!

    I’m using a frontend form that was working until one of the last acf updates. Now getting an error: Undefined offset: 1 in ...\wp-content\plugins\advanced-custom-fields-pro\includes\api\api-helpers.php on line 4639

    get_header();
    acf_form_head();
    ...
    <?php if (!strpos($_SERVER['REQUEST_URI'], '?thank-you')) : ?>
      <?php the_content(); ?>
      <?php
      $fields = array( // Field groups
        'field_5d0d0b6322401',
        'field_5d0d0bbc22403',
        'field_5d238bd5e3433'
      );
      acf_register_form(array(
        'id'       => 'new-cpt-name',
        'post_id'  => 'new_post',
        'new_post' => array(
          'post_type'   => 'cpt-name',
          'post_status' => 'draft',
        ),
        'post_title'   => false,
        'post_content' => false,
        'uploader'     => 'basic',
        'return'       => get_the_permalink(get_the_ID()).'?thank-you',
        'fields'       => $fields,
        'submit_value' => 'Submit your cpt-name',
        'html_submit_button'  => '<input type="submit" class="btn btn-primary" value="%s" />'
      ));
    
      acf_form('new-cpt-name');
      ?>
    
    <?php else : ?>
      <h2>Thanks for submitting your request!</h2>
      <p>A {...} website administrator will contact you within a week of your submission and provide a link to your custom {...}.</p>
    <?php endif; ?>

    Couple things I’ve tried:
    1. Using output buffering around acf_form_head

    ob_start();
    get_header();
    acf_form_head();
    echo ob_get_clean();

    2. Removing the server request conditional.

    3. Another dev thought it may have to do with acf_validate_value() within \wp-content\plugins\advanced-custom-fields-pro\includes\validation.php , but I could not quite see the issue there.

    Confirmed that this is working with an older version of ACF (5.6.9 I believe).

    Thanks for any help or suggestions with this one!

  • Unread

    Send acf_form() through Ajax

    How sent acf_form() through Ajax without page refresh???
    This function from my web-site:
    <?php
    acf_form_head();
    get_header();
    ?>

    <?php

    acf_form(array(
    ‘post_id’ => ‘new_post’,
    ‘post_content’ => false,
    ‘new_post’ => array(
    ‘post_type’ => ‘post’,
    ‘post_status’ => ‘publish’
    ),
    ‘html_submit_button’ => ‘<input type=”button” class=”acf-button button button-primary button-large” onclick=”send_form()” value=”%s” />’,
    ‘submit_value’ => ‘Опубликовать’
    ));

    ?>

  • Solved

    Dynamically Set A Front-End Form Field

    Hi guys,

    I really hope you guys can help me out. I have been bashing my head around how to get this right.

    I have a front-end form that I use to receive Candidate Applications.
    I have two custom post types – Vacancies and Candidates.

    On the Candidates custom post type I have created a number of fields (all work on the front-end form) – one of which is a text field called Vacancy Applied For. What I want is for this field to be dynamically populated with the specific vacancy that has been applied for.

    This is the code for registering the Candidate Application Form.

    // Register ACF Forms for Front-End
    // 1. Candidate Application Form
    
        //Defines the fields to display
        $fields = array(
            'field_5db9db36a28bf',	    // candidate first name
            'field_5e05d834dcb14',      // candidate last name
            'field_5db9db5da28c0',	    // candidate email
            'field_5db9dc8ca28c1',	    // candidate contact number
            'field_5dcc08f0a11b5',      // candidate gender
            'field_5dcc092ba11b6',      // candidate race
            'field_5dcc09e2a11b7',      // candidate nationality check
            'field_5dcc0a32a11b8',      // candidate nationality
            'field_5db9dd10a28c2',	    // candidate cv
            'field_5db9ddf5a28c4',      // candidate supporting docs
            'field_5dba152669aaf',      // candidate vacancy applied for
            'field_5dcc0f15030b6'       // candidate disclaimer
    
        );
    
        // Sets the ACF Form
        acf_register_form(
    
        // Defines all the settings associated with the ACF Form 
        array(
    
            /* (string) Unique identifier for the form. Defaults to 'acf-form' */
            'id' => 'acf-candidate-application-form',
    
            /* (int|string) The post ID to load data from and save data to. Defaults to the current post ID. 
            Can also be set to 'new_post' to create a new post on submit */
            'post_id' => new_post,
    
            /* (array) An array of post data used to create a post. See wp_insert_post for available parameters.
            The above 'post_id' setting must contain a value of 'new_post' */
            'new_post' => array(
                'post_type'		=> 'candidates',
                'post_status'	=> 'publish',
            ),
    
            /* (array) An array of field group IDs/keys to override the fields displayed in this form */
            'field_groups' => false,
    
            /* (array) An array of field IDs/keys to override the fields displayed in this form */
            'fields' => $fields,
    
            /* (boolean) Whether or not to show the post title text field. Defaults to false */
            'post_title' => false,
    
            /* (boolean) Whether or not to show the post content editor field. Defaults to false */
            'post_content' => false,
    
            /* (boolean) Whether or not to create a form element. Useful when a adding to an existing form. Defaults to true */
            'form' => true,
    
            /* (array) An array or HTML attributes for the form element */
            'form_attributes' => array(),
    
            /* (string) The URL to be redirected to after the form is submit. Defaults to the current URL with a GET parameter '?updated=true'.
            A special placeholder '%post_url%' will be converted to post's permalink (handy if creating a new post)
            A special placeholder '%post_id%' will be converted to post's ID (handy if creating a new post) */
            'return' => get_home_url('candidate-application-success'),
    
            /* (string) Extra HTML to add before the fields */
            'html_before_fields' => '<input type="text" id="field_5dba152669aaf" name="field_5dba152669aaf" value="test" style="display:none;">',
    
            /* (string) Extra HTML to add after the fields */
            'html_after_fields' => '',
    
            /* (string) The text displayed on the submit button */
            'submit_value' => __("Submit Application", 'acf'),
    
            /* (string) A message displayed above the form after being redirected. Can also be set to false for no message */
            'updated_message' => __("Application successfully submitted", 'acf'),
    
            /* (string) Determines where field labels are places in relation to fields. Defaults to 'top'. 
            Choices of 'top' (Above fields) or 'left' (Beside fields) */
            'label_placement' => 'left',
    
            /* (string) Determines where field instructions are places in relation to fields. Defaults to 'label'. 
            Choices of 'label' (Below labels) or 'field' (Below fields) */
            'instruction_placement' => 'field',
    
            /* (string) Determines element used to wrap a field. Defaults to 'div' 
            Choices of 'div', 'tr', 'td', 'ul', 'ol', 'dl' */
            'field_el' => 'div',
    
            /* (string) Whether to use the WP uploader or a basic input for image and file fields. Defaults to 'wp' 
            Choices of 'wp' or 'basic'. Added in v5.2.4 */
            'uploader' => 'basic',
    
            /* (boolean) Whether to include a hidden input field to capture non human form submission. Defaults to true. Added in v5.3.4 */
            'honeypot' => true,
    
            /* (string) HTML used to render the updated message. Added in v5.5.10 */
            'html_updated_message'	=> '<div id="message" class="updated"><p>%s</p></div>',
    
            /* (string) HTML used to render the submit button. Added in v5.5.10 */
            'html_submit_button'	=> '<input type="submit" class="acf-button button button-primary button-large" value="%s" />',
    
            /* (string) HTML used to render the submit button loading spinner. Added in v5.5.10 */
            'html_submit_spinner'	=> '<span class="acf-spinner"></span>',
    
            /* (boolean) Whether or not to sanitize all $_POST data with the wp_kses_post() function. Defaults to true. Added in v5.6.5 */
            'kses'	=> true
    
        )
    );
    

    This is the code I’m using on the page template where I am using the front-end form.

    <?php
    /**
     * Template Name: Candidate Application Form Page
     * Description: The template for displaying the Candidate Application Page.
     *
     */
    $vacancy = isset( $_GET['vacancy'] ) ? esc_attr( $_GET['vacancy'] ) : '';
    $vacancyurl = isset( $_GET['vacancyurl'] ) ? esc_attr( $_GET['vacancyurl'] ) : '';
    
    function my_pre_save_post( $post_id ) {
    
        // check if this is to be a new post
        if( $post_id != 'new_post' ) {
            return $post_id;
        }
        // Create a new post
        $post = array(
            'post_status'  => 'publish' ,
            'post_type'  => 'Candidates' ,
        );
    
        $post_id = wp_insert_post( $post );
    
        $field_key = "field_5dba152669aaf";
        $value = $vacancy;
        update_field( $field_key, $value, $post_id ); 
        return $post_id;
        echo $value;
    }
    
    add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1 );
    
    acf_form_head();
    get_header();
    
    ?>
        
    
    	<div id="primary" class="content-area">
    		<div id="content" class="site-content" role="main">
                <div class="candidateformcontainer">
                
                    <?php /* The loop */ ?>
                    <?php while ( have_posts() ) : the_post(); ?>
                        <div>
                           <h1><?php echo get_the_title(); ?></h1>
                            <p>To proceed with submitting your application for <strong><?php echo $vacancy; ?></strong> complete the application form below.</p>
                        </div>
                        <?php 
    
                        acf_form('acf-candidate-application-form'); 
                            
                        ?>
    
                    <?php endwhile; ?>               
    
                </div>
    
    		</div><!-- #content -->
    	</div><!-- #primary -->
    
    <?php get_footer();
    
    // Omit Closing PHP Tags

    When I echo the $vacancy variable it is being passed to the page (I set it based on the button clicked on the Vacancies page. It just won’t pass into the field and save.

    I have also tried to use the code snippet from the Update Field page. This passes the $vacancy variable into the post when I click submit on my front-end form but I then have two posts that get created. One with all the values from the form (without the Vacancy Applied For field set to the $vacancy variable and a second post with no post data passed to it except the Vacancy Applied For field set to the $vacancy variable.

    This is the code (also placed on the page template)

    $post_data = array(
        'post_type'     => 'candidates',
        'post_status'   => 'publish'
    );
    $post_id = wp_insert_post( $post_data );
    
    // Save a basic text value.
    $field_key = "field_5dba152669aaf";
    $value = $vacancy;
    update_field( $field_key, $value, $post_id );

    Any help would be awesome! I’m stuck and its probably a silly mistake but I can’y figure it out.

  • Unread

    ACF Google Maps output

    I’ve seen a few posts on this but none nail what I need.

    I’m trying to output the address from the Google Map field, so far I’ve used;

    $location = get_field('address', 'options');
    if( $location ) {
    
        // Loop over segments and construct HTML.
        $address = '';
        foreach( array('street_number', 'street_name', 'city', 'state', 'post_code', 'country') as $i => $k ) {
            if( isset( $location[ $k ] ) ) {
                $address .= sprintf( '<span class="segment-%s">%s</span><br>', $k, $location[ $k ] );
            }
        }
    
        // Trim trailing comma.
        $address = trim( $address, ', ' );
    
        // Display HTML.
        echo '<p>' . $address . '</p>';
    }

    Which outputted it as;
    6
    David Lane
    England
    NG6 0JU
    United Kingdom

    However, I need it to output for the UK as;
    6 David Lane
    Nottingham
    NG6 0JU
    United Kingdom

    Anyone work out why Nottingham isn’t showing and 6 has it’s own line?

Viewing 25 results - 26 through 50 (of 281 total)