Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • So the code above provided by @ihorvorotnov to hook on muplugins did not work for me but ffraenz/private-composer-installer that he suggested did to install the plugin via composer.

    In order to include the plugin in my theme, I first changed the package type to library, instead of wordpress-plugin, that way it installs in the vendor folder since I had to use composer within my theme (see below).

    Then I used this official resource and just replaced the paths with those that composer creates i.e., /vendor/advanced-custom-fields/advanced-custom-fields-pro/.

    The use-case is that I scaffold many projects the same way and it’s always been a PITA to have a scaffold that requires I install both Timber and ACF Pro to get up and running; I mean what’s the point of a scaffold if it doesn’t scaffold everything that’s needed.

    Since Timber is either installed as a WordPress plugin from WordPress (what I want to avoid) or via composer from within the theme and not as a "type": "wordpress-plugin", which means that it won’t install into wp-content/plugins/ annoyingly enough, either Yeoman would have to run two composer installs, one in the root directory of WordPress and the other from within the theme, or I had to figure out how to combine them. The easiest way is to include ACF Pro in the theme, plus I like that it is locked down since all my work is premium custom-tailored theme development.

  • I had misunderstood your question… this is something I can use too… I will dedicate the next weekend to experiment with this, and I’ll post back here if I manage to find a solution. I’ve done 51 ACF blocks, bunch of Block Patterns (which are awesome and very easy to do), but never a template… time to dive into templates I guess now…

  • No i’m making a block template. So when the admin is creating a new page the prefered blocks are already there with the required settings already set. See link in original question.

    Now the placement of the blocks core and acf is working when I click on new page, but how to set a specific field on a specific value.

    For example on a page i want te use

    Code/image
    ACF/columns (set 2 columns)
    ACF/columns (set 3 columns)

    The field columns in the block columns need to get set in ‘data’ i think but I can’t find how.

    Thanks,
    Noraly

  • Your question is not clear. Did you register your block to start in the preview mode? Then, when you load the block, you need to switch to edit mode. Or, if you registered the block in auto mode, then simply click on the block to automatically change it to the edit mode. Are you talking about having default values? You do that in the Field Groups when creating the fields… I can go on and on…

    P.S Clicking the pencil icon on the toolbar will change the mode to edit, and when you click on the Monitor icon next, you will go back from the edit mode to the preview mode.

    Follow the example found on this page: https://www.advancedcustomfields.com/resources/blocks/

    and continue reading this: https://www.advancedcustomfields.com/resources/acf_register_block_type/

    I hope you can solve your issues !

  • Hello, please Someone could answer my question, I would be very grateful Thank you very much.

  • Hi @elliot,

    We’re still having the same issue, not only with draft preview, but also with published posts when set to private.

    ACF version: 5.8.9
    WordPress version: 5.4

    Is there a quick fix for that? also, happy to share more information as needed, to help resolving that issue, it sounds like a common glitch, so would be very helpful to address it as soon as you get a chance, thank you for your support.

    All best,
    MADEO Dev

  • SOLVED
    my link is like https://domain/?user=1&parent=165
    i place this code into my page template

     <?php
    if (isset($_GET['user']))
    {
        $user = $_GET['user'];
    } else {
    	$user = '1';
    }
    	acf_form(array(
    	 'id' => 'form',
             'post_id' => 'new_post',
             'field_groups' => array(ID), // Used ID of the field groups here.
             'post_title' => true, // This will show the title filed
             'post_content' => false, // This will show the content field
             'form' => true,
             'new_post' => array(
                 'post_type' => 'customer_data',
    			 'post_author' => $user,  // Where $user_id is a number
                 'post_status' => 'publish' // You may use other post statuses like draft, private etc.
             ),
    		 // 'return' => '/?user=' . $user . '&parent=%post_id%',
             'submit_value' =>__("Submit Addons", 'acf'),
    		 'html_submit_button'  => '<input type="submit" id="next" class="acf-button button button-primary button-large" name="addons_btn" value="%s" />
    		 <input type="submit" id="done" class="acf-button button button-primary button-large" value="Submit Details" style="position: relative; float:right;" />',
         ));
    ?>

    add some JS

    <script type="text/javascript"> 	
    $(document).ready(function(){
    	$("#next, #done").click(function(e) {
    		$("<input />").attr("type", "hidden")
    			.attr("name", "acf[submittype]")
    			.attr("value", e.target.id)
    			.appendTo("#form");
    	});
    });
    </script>

    I also add some code on functions.php

    add_action('acf/submit_form', 'my_acf_submit_form', 10, 2);
    function my_acf_submit_form( $form, $post_id ) {
    	if ($_POST['acf']['submittype'] == 'next') {
    		wp_redirect( 'first_link');
    	} else {
    		wp_redirect('another_link');
    	}
        exit;
    }
  • SOLVED

    i use javascript to set value

    <script type="text/javascript"> 	
    $(document).ready(function(){
    	$.urlParam = function(name){
    		var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    		return results[1] || 0;
    	}
    	$("input[name='acf[%FIELD NAME%]']").val($.urlParam('parent'))
    });
    </script>

    Change “FIELD NAME” with field name like [field_5e8d66375739f]

  • Use a format value filter

    2 fields

    
    add_filter('acf/format_value/name=phone_field', 'convert_phone_to_link', 20, 3);
    function convert_phone_to_link ($value, $post_id, $field) {
      if (!$value) {
        // no value
        return $value;
      }
      // get the tel link field
      $tel_link = get_field('tel_link_field')
      if (!$tel_link) {
        // no link
        return $value;
      }
      $value = '<a href="tel:'.$tel_link.'">'.$value.'</a>';
      return $value;
    }
    

    1 field

    
    add_filter('acf/format_value/name=phone_field', 'convert_phone_to_link', 20, 3);
    function convert_phone_to_link ($value, $post_id, $field) {
      if (!$value) {
        // no value
        return $value;
      }
      // assumes US number
      $tel_link= '+1'.preg_repace('/[^0-9]/', '', $value);
      $value = '<a href="tel:'.$tel_link.'">'.$value.'</a>';
      return $value;
    }
    
  • I am waiting for the ACF Custom Database Tables to support Repeater fields, before I buy it. If you don’t use repeater fields it would be worth spending the money and getting it now, however if most of the data will be stored in repeater fields, the current version would be near useless, or more politically correct putting, less helpful…

    Unless you need front end forms, and complex front end searches, a better solution for keeping the database small might be to create your project using ACF blocks instead of Custom Fields. The database size difference between using Blocks Vs custom fields will be astronomical, very quickly!

  • Sorry to bring back an old thread, but is there a way to do this using the acf/update_value filter?

    Meaning, what code would fire:

    $phone = get_field('phone-number');
    <a href="tel:<?php echo $phone; ?>"><?php echo $phone; ?></a>

    on all pages, so everywhere the phone-number value appears it is replaced with the linked version?

    Thanks.

  • Ok I had to return post_id for it to be saved.
    Still, I don’t get why with this code, when the honeypot ‘surname3’ is not empty, the form still get saved, altough completely empty.

    Isn’t die supposed to terminate the whole process?

    function my_honey_pot( $post_id ) {
    	if(! empty($_POST['surname3'])){
    		die("");
        } else {
    		return $post_id;				
    	}
    }
    add_action('acf/pre_save_post' , 'my_honey_pot'  );
  • Hi all,

    I’m having the same issue with Flexible Content & Foundation’s Tabs.

    I need to loop through first time to get the tab titles, and second time to get the content but second loop isn’t fetching the correct data.

    
    <ul>
        <!-- While Loop 1 -->
        <li class="tabs-title is-active"><a href="#$title">$title</li>
        <li class="tabs-title"><a href="#$title">$title</li>
        <li class="tabs-title"><a href="#$title">$title</li>
        <!-- /While Loop 1 -->
    </ul>
    
    <div class="tabs-content">
        <!-- While Loop 2 -->
        <div class="tabs-panel is-active" id="$title">
            <p>$content</p>
        </div>
        <div class="tabs-panel" id="$title">
            <p>$content</p>
        </div>
        <div class="tabs-panel" id="$title">
            <p>$content</p>
        </div>
        <!-- /While Loop 2 -->
    </div>
    

    Any solutions out there?

    Thanks

  • I don’t see the wp-config concern as enough of a reason to prevent this given how many other plugins and values such as DB credentials are already following that pattern.

    It would be great if WP supported .env files natively, it’s definitely the proper place for config values.

    Agreed. Until that is part of core, using https://github.com/vlucas/phpdotenv isn’t that much overhead as an included composer package. The roots.io team has a good write-up of how they’ve incorporated into their repo structures, build pipelines, etc. But chances are if wp-config has been committed with values to git, adding a composer dependency may be beyond the same user base :/

  • I’m interested why you don’t think 300 rows is a good idea – surely a CPT has more database overhead?

    Anyway, this post helps;

    https://felicoz.com/en/2017/05/acf-import-repeater-field-values-csv-programmatically/

    if you add the line
    add_row('repeater_name', array("","")); in the while loop, (obviously as many empty values as sub fields), then it will add the rows too.

  • I have similar issues on a site I’m developing. I think @herry is onto something.

    Why not create a simple mechanism for lazy loading repeater items on request?

    This could be activated using a filter and would hide all of a repeters fields until a “show fields” link is clicked.

    This should be pretty easy to implement and we would be able to stop ACF from loading and saving hundreds of files every time a page is edited.

    It would solve all (most) performance related problems that backend users are experiencing due to having to many repeater (or equivalent) fields.

  • Take a look at this page: https://www.advancedcustomfields.com/resources/image/

    I’d set the return value of the custom image field to Image URL and put something like this in your template:

    <?php 
    $taxonomy_image_src = get_field('image_indicateur_confiance');
    
    if ($taxonomy_image_src) { ?>
    
        <img src = "<?php echo $taxonomy_image_src;?>">
    
    <?php } ?>
  • Only if you use ACF functions to show the field.

    I’m need to use this with visual composer “postgrid”.

    Visual composer’s postgrid is not using ACF functions. You’ll need to use filters provided by what you’re using.

  • May be I resolved by myself.

    My setting is here.

    [Current User] [is equal to] [Viewing frontend] and
    [Current User] [is equal to] [Logged in]
    // For showing field group form on original Profile page. Like /profile-edit
    // For not showing field group form on Register page. Like /wp-login.php?action=register

    This is working now.Thanks.
    And I write down my second setting as well.

    [Current User] [is equal to] [Viewing frontend] and
    [Current User] [is equal to] [Logged in]
    // These are same as above.
    or
    [User Form] [is equal to] [All]
    [Current User] [is equal to] [Logged in]
    // For showing on Admin users page. User Checking and Editing is easy.
    // For not showing on register page. [User Form] shows forms every wehre, so.

    ACF guys you are the best! I love Victoria bitter too.

  • How to get woocommerce product in the 4 columns in frontend homepage. I’m using a template file. Can you send me to code how show product in frontside?

    I’m using Field Type: Post Object.

    I have attached screenshot, please check.
    Thank you in advance.

    custom-filds….png

    product-list….png

    having problem like this .

  • Not 100% sure what you mean. If this field is for a post and you want to get the sum of all fields for all posts then you must do a query to get all the posts, loop over them, get the field value an add them up. You don’t need to show the posts but you still need to get them and loop over them.

  • OK, got it.

    There are a couple of issues here, including zero validation.

    My Form:

    
    <?php
    
    acf_form_head();
    
    $avatar_group = get_field( 'sys_avatar_field_group', 'option' );
    $current_user = wp_get_current_user();
    
    $user_id = get_current_user_id();
    $user_acf_prefix = 'user_';
    $user_id_prefixed = $user_acf_prefix . $user_id;
    
    $user_info = get_userdata($user_id);
    $member_email = $user_info->user_email;
    
    $options = array(
    	'post_id' => 'user_'.$current_user->ID,
    	'field_groups' => array(group_5e880597057c0, $avatar_group),
    	'submit_value' => 'Update Profile'
    );
    
    ?>
    

    Validation:

    
    /** User Meta Update Validation ------------------------------------------------ **/
    
    add_action('acf/validate_save_post', 'validate_user_input_data');
    function validate_user_input_data() {
    
      $email = $_POST['acf']['field_5e880d5caa23d'];
      $user_info = get_userdata($user_id);
      $current_email = $user_info->user_email;
    
      if ( empty($_POST['acf']['field_5e880d5caa23d']) ) {
        acf_add_validation_error( 'acf[field_5e880d5caa23d]', 'You need to specify an email address' );
      }
    
      elseif ( email_exists($email) && $email != $current_email ) {
        acf_add_validation_error( 'acf[field_5e880d5caa23d]', 'The email address you entered is not available' );
      }
    
    }
    

    Update function:

    
    /** User Meta Update ------------------------------------------------ **/
    
    function update_member_data( $post_id ) {
    
    	if( empty($_POST['acf']) ) {
    		return;
    	}
    	
    	if( is_admin() ) {
    		return;
    	}
    	
    	if( $_POST['post_id'] != 'new' ) {
    		
    		$memberEmail = $_POST['acf']['field_5e880d5caa23d'];
    		$user_id = str_replace("user_", "", $post_id);
    		
        $args = array(
         'ID'         => $user_id,
         'user_email' => esc_attr($memberEmail)
       );
        wp_update_user($args);
    
        $memberFirstname = $_POST['acf']['field_5e880c9b0e92d'];
        $memberLastname = $_POST['acf']['field_5e880d0daa23b'];
        $memberNickname = $_POST['acf']['field_5e880d3baa23c'];
        $memberDisplayname = $_POST['acf']['field_5e886a3273989'];
    
        update_user_meta($user_id, 'first_name', $_POST['acf']['field_5e880c9b0e92d'] );
        update_user_meta($user_id, 'last_name', $_POST['acf']['field_5e880d0daa23b'] );
        update_user_meta($user_id, 'nickname', $_POST['acf']['field_5e880d3baa23c'] );
        update_user_meta($user_id, 'display_name', $_POST['acf']['field_5e886a3273989'] );
      }
      return $post_id;
    }
    add_action('acf/save_post', 'update_member_data', 20);
    

    Note: wp_update_user does not handle meta updates, you need to use update_user_meta.

    Graeme

  • Yes, you can achieve this using the WordPress WP_Query and passing advanced custom fields to it with a meta query. Instructions on how to do this can be found here: https://www.advancedcustomfields.com/resources/query-posts-custom-fields

    Brilliant, thanks for sharing this info. This is all very interesting 🙂

  • The problem has been resolved.

            <?php
                if( have_rows('authors') ): while ( have_rows('authors') ) : the_row();
            ?>
            <div class="entry-author ">
                <?php $author_id = get_sub_field('user')['ID']; ?>
                <div class="pic">
                    <a rel="author">
                        <img alt='' src='<?php echo get_field('image', 'user_' . $author_id )['url']; ?>'
                            class='avatar avatar-160 photo' height='160' width='160' />
                    </a>
                </div>
                <div class="info">
                    <h2 class="name"> <a href="<?php echo get_author_posts_url($author_id, $author_nicename) ?>"
                            rel="author"><?php echo get_sub_field('user')['display_name']; ?></a></h2>
                    <div class="desc"><?php echo get_field('role', 'user_' . $author_id); ?></div>
                    <div class="desc"><?php echo get_field('bio', 'user_' . $author_id); ?></div>
                </div>
            </div>
            <?php endwhile; endif; ?>
            <?php endif; ?>
Viewing 25 results - 7,001 through 7,025 (of 21,361 total)