Support

Account

Forum Replies Created

  • In case anyone else tries to do something like this, not sure if this is a legit way of doing it, but it seems to work:

    search.val( $('.event_venue_address input').val() ).promise().done(function(){ acf.fields.google_map._search( e ); });

  • If you are using local JSON feature or PHP register, you can edit the JSON and add in the extra:
    'readonly': 1

    @elliot, unfortunately, this setting doesn’t stick if you update the field after making this change. Any saves to the ACF group will overwrite all readonly and disabled customizations back to 0.

    It’d really be great to see this feature usable.

    Thanks!

  • Thanks. That’s what I’ve been doing, just thought there might be a way that didn’t relay on the DOM objects. Reason being, as we were working on this, I think I was accessing something where the class name changed in a recent update you pushed out and obviously things stopped working as expected. We found the change and all went back to normal, but this isn’t ideal.

    Appreciate the responses and we’ll continue to push forward and hope you don’t change the class names again. 🙂

  • Thanks, @elliot

    One more question. If we use {type: ‘repeater’} is there then an easy way to loop through each of the repeater rows/objects so we’re are relying on the classes to find things?

  • Thanks, Elliot. This is helpful. What are the other parameters we can use here? For example, can we target a specific field by name or all fields within a specific repeater?

    To get some insight, here is our current code that works well, but not sure if it is the best way about it. For example, if you decide to change the class names (which you did in a recent update, this approach will break):

    acf.add_action('load', function($el){
              // Loop through each ACF field
              acf.get_fields().each(function(){
    
                // Specific for Repeaters
                var table = $(this).parents('.acf-table-wrap'), // Get the table wrapper for the repeater
                    row = table.parent('.acf-row'), // Get the acf-row containing everything
                    hidden = table.find('[data-name="<?php echo self::UNIQUE_ID_FIELD_NAME; ?>"] input'); // Get the unique_id hidden field
                // Check if the unique_id field has a value
                if(hidden.length != 0 && hidden.val().length != 0){
                  // We are looking at a parent item since the unique_id is set
                  var remove_row = row.find('.acf-repeater-remove-row'),
                      input = $(this).find('.acf-input'), // Get the input wrapper for the field
                      field_name = $(this).data('name'),
                      field_type = $(this).data('type'),
                      field = null,
                      data = null;
    
                  if(field_type == 'wysiwyg'){
                    field = input.find('.acf-editor-wrap');
                    data = field.find('textarea').val();
                  } else {
                    switch(field_name){
                      case '<?php echo self::ACF_TOPIC_TITLE; ?>':
                        field = input.find('input');
                        data = field.val();
                        break;
                    }
                  }
    
                  if(field != null){
                    // Hide the entire WYSIWYG field
                    field.hide();
                    // Hide remove icon/ability
                    remove_row.css('visibility', 'hidden');
                    // Display the data from the WYSIWYG field
                    input.append(data);
                  }
                }
                // End Repeaters
    
              });
            });
  • With some custom coding…I’m guessing you could hook into acf/save_post: http://www.advancedcustomfields.com/resources/acfsave_post/

    And then use set_post_thumbnail: http://codex.wordpress.org/Function_Reference/set_post_thumbnail

    That should get you started.

  • @wells5609 Awesome! You lead me to try something that got me to the answer.

    I can’t do exactly what you said cause I needed to do the get_fields call for some other data. But, your answer prompted me to try:

    $field = get_field_object($question, 'user_'.$userid, array('load_value' => false));

    Essentially adding in the user_ID# instead of passing in FALSE. This did the trick for me. Not sure why I didn’t try that before!

    Thanks!

  • You can find the plugin here: http://wordpress.org/plugins/simple-wp-firephp/ (hasn’t been updated in a long time, but I don’t think there is much to update)

    And the FirePHP details: http://www.firephp.org/

    Thanks for the help, @emcniece!

  • Ha! I found the issue with the code and then found the issue with the rest…

    First: my switch statement was
    switch ($field)
    when it should be
    switch ($field['name'])

    After fixing that, I figured out the call wasn’t actually happening on page.php OR within the if statement! Not sure why though.

    In any case, my final code, within the functions.php file is:

    add_filter('acf/update_value', 'nwr_acf_update_profile', 10, 3);
    
    function nwr_acf_update_profile($value, $post_id, $field) {
    	if (bbp_is_single_user_edit()):
    		$current_user = wp_get_current_user();
    		if (current_user_can('edit_user', $current_user->ID)):
    			$userdata = array('ID' => $current_user->ID);
    			switch ($field['name']):
    				case 'user_first_name':
    					if ($value != $current_user->first_name):
    						$userdata['first_name'] = $value;
    					endif;
    					break;
    			endswitch;
    			if (count($userdata) > 1):
    				wp_update_user($userdata);
    			endif;
    		endif;
    	endif;
    	return $value;
    }
  • Yeah! Thanks for the effort, @emcniece.

    @elliot – I see you are using bbpress for this forum, are you doing anything like this? Maybe Genesis is the issue for me? Thoughts?

    Thanks.

  • Well, at this point in the code, I don’t think an echo will work. I actually have the Simple Fire PHP plugin installed for debugging PHP in the console for just this and no, it doesn’t seem to be firing. That said, I tested the other update_value call I’m using in another section of the site and the FirePhP code didn’t work there either, but that filter works. So that wasn’t helpful.

    Further, I did try putting it in functions.php to no avail. The way Genesis works is that it actually allows you do have custom filters/actions on a per page/template basis, outside of functions since the page isn’t called/rendered until the genesis() call is made at the end of the file.

    The only difference between how I’m calling this filter that isn’t working at the the one that is working is that the one that is working is all on one page. This one that isn’t, the filter is on page.php, however, the acf_form call is actually on form-user-edit.php (which is called from page.php in bbpress). However, since I’m using Genesis, I’m not sure how to get everything together (if that is the issue). That said, if that is the issue, putting the filter in functions.php should resolve that, however, it doesn’t.

    And therefore, I’m still stumped…

  • Looks like it is there:

    Array
    (
        [5] => Array
            (
                [000000004f2d8d300000000032cd93ceupdate_value] => Array
                    (
                        [function] => Array
                            (
                                [0] => acf_field_functions Object
                                    (
                                    )
    
                                [1] => update_value
                            )
    
                        [accepted_args] => 4
                    )
    
            )
    
        [20] => Array
            (
                [nwr_acf_update_profile] => Array
                    (
                        [function] => nwr_acf_update_profile
                        [accepted_args] => 3
                    )
    
            )
    
    )
  • No, the filter doesn’t fire when not wrapped. I tried that as well as placing it directly in the functions.php file. Nothing.

    I just tried firing it with priority 5 and 20, still nothing.

    I’m really banging my head against the wall on this one.

    Thanks, emcniece. Let me know if you have any other ideas.

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