Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hey Elliot, sorry for the delay.

    How about using the PHP native function for detecting whether magic quotes is enabled on a particular setup?
    http://php.net/manual/en/function.get-magic-quotes-gpc.php

    If magic quotes is enabled, you can use the stripslashes_deep() call, and skip it otherwise. For example:

    if ( get_magic_quotes_gpc() ) {
      $value = stripslashes_deep( $value );
    }
    

    In place of the offending line:
    https://github.com/elliotcondon/acf/blob/36422e64320045e665b4b98349c4d2bfda7edaa2/core/fields/_functions.php?#L188

  • Hi @hummelmose

    Sorry, did you understand my previous comment? Seems like you have gone in a completely different direction to what I have just said.

    WP looks at the URL and then runs the appropriate template. On the template you can use ACF to load the custom field data.

    If this is not what you want, please re-describe your question with more clarity.

    Thanks
    E

  • Hi @Sammy262

    This will be possible by using a different technique to loop the repeater field data. Instead of using the_repeater_field, you will need to use a more basic PHP aproach as demonstrated on this page:
    http://www.advancedcustomfields.com/resources/field-types/repeater/
    See example – Taking a more basic PHP aproach.

    After you have stored the value as a variable, but before the loop, you can randomize the rows like so:

    
    shuffle( $gallery )
    

    Good luck!

    Thanks
    E

  • Hi @hummelmose

    Firstly, when you view the page in quesiton, you will run the page.php template in your theme.

    Edit this template file and add some code like so:

    
    $url = get_field('old_article_id');
    var_dump( $url );
    

    Do you see your url? If so, you can easily redirect via PHP. WP even has a function called wp_redirect I believe

  • Hi @Nuro

    I’m starting to understand the question but again, I have too many questions regarding the repeater field and what exactly you are trying to do.

    Screenshots will help.

    Heres some info:
    1. You can upload multiple images at once using the repeater field.
    2. If all your titles are pre-defined, why put them into a field, why not put them into the template?

  • Hi @higgypop

    Seems like you have created a duplicate thread:
    http://support.advancedcustomfields.com/forums/topic/user-field-user-id/

    Answer is in that thread

  • Hi @juxprose

    Thanks mate. Can you change this topic to a question and mark the appropriate reply as the solution?

  • Hi @Brugman

    It is not possible to create top level options pages at the moment.
    Thanks for the feature request. I’ll keep it in mind.

    Thanks
    E

  • Hi @youngwolf0

    A very good question. To which I don’t have an easy solution.

    I would write a custom function (and run it once, then delete it) that loops through all your users (via a WP_User query), and for each user, use the update_field function (documented on this site) to save a value of 1 for the field.

    I hope this makes sense.

    Thanks
    E

  • Hi @lkamms

    Sounds like you have upgraded from ACF v3.x to v4.x

    This transition introduced a new way to create field types. v3 field types are no longer compatible with v4 (this is heavily documented).

    I believe that your website contains a ‘buy now’ field type which was built from v3, but not for v4.

    My advice would be to contact the dev team from the build and ask them if this is the case. If so, I would hire them to rebuild the field into a v4 compatible version. This is a pretty simple task as there is a starter kit available on github and documentation on the resources page.

    Hope that helps.

    Thanks
    E

  • Hi @ever-e

    You will find all the relevant information in this article:
    http://www.advancedcustomfields.com/resources/tutorials/creating-a-front-end-form/

    Please note, the ACF plugin requires you to know your way around PHP and WP development. Especialy creating a page template with front end publishing capabilities.

    I wish you good luck!

    Thanks
    E

  • Hi @Nuro

    Good description, however, I am a bit lost due to not seeing the repeater field in question. Can you post some screenshots to help me see and understand how you want the data to automate?

    My first idea is to hook into a WP action which is fired when WP creates an autosave post (when you first edit a new post). Your function could then just insert the default values and then when the page loads, your default values will exist!

  • Hi @refreshingdesign

    Good question.
    To modify the DOM without reloading the page, you will need to write some custom jQuery on the edit screen.

    You could either use an AJAX call to allow PHP to return the choices, or just look at the text inputs to generate the choices.

    To add a script tag to the edit screen, use the acf/input/admin_head action.
    You find some examples of this action on the docs (actions) page.

    Cheers
    E

  • Hi @Nathan

    Yes, if the post_object field was used and only a single value was saved per repeater row, you could use this guide to query the posts that contiain a sub field value!

    http://www.advancedcustomfields.com/resources/tutorials/querying-the-database-for-repeater-sub-field-values/

    Good luck

    Cheers
    E

  • Hi @aaronrobb

    Perhaps instead of if ($field['choices']){, you could look at the type as suggested in your topic title like so:

    
    if ($field['type'] == 'radio'){
    

    As for the yes / no question, I’m completely lost as to what you are trying to achieve. Would you mind explaining the result you want?

    Thanks
    E

  • Hi Elliot,

    In you original reply in this thread, you allude to this being possible using the post_object field rather than the relationship field, is that correct?

    I’ve got a repeater field on a page for listing awards, which contains sub fields for ‘award-name’, ‘award-year’ and ‘award-project’ (the last of which is a post_object field, limited to the ‘projects’ custom post type.

    I’m looking to query that on the single projects template, to display the name and year of any awards that have that project set for award-project.

    (I know it would be much easier to do it the other way around, having the award set on the project itself and then querying them on the awards page, but I need to allow for some awards not having a project associated with it.)

    Cheers

  • Somehow I solved this. I read through the info on the repeater plugin page again and modified my code. Didn’t see any obvious changes, but this snippet is working now.

    <?php if(get_field('summary_section')): ?> 
      <div class="section-head"><h2>Summary</h2></div>
          <?php while(has_sub_field('summary_section')): ?>
          <ul>
            <li class="bulletin-data-item"><h3>Bulletin Summary</h3><?php the_sub_field('bulletin_summary'); ?></li>
            <li class="bulletin-data-item"><h3>Location</h3><?php the_sub_field('location'); ?></li>
            <li class="bulletin-data-item"><h3>Report Number</h3><?php the_sub_field('report_number'); ?></li>
            <li class="bulletin-data-item"><h3>Incident Date</h3><?php the_sub_field('incident_date'); ?></li>
            <li class="bulletin-data-item"><h3>Incident Time</h3><?php the_sub_field('incident_time'); ?></li>
            </ul>
         <?php endwhile; ?>
    <?php endif; ?>
  • I’ve somehow gotten rid of the endwhile syntax error by cleaning up the comments elsewhere in the template.

    But I’m still left with no data displaying. I’ve fleshed out the snippet with the rest of the fields from that repeater field. This is the full code bit that I currently have, but still nothing displays.

    <div class="patrol-bulletin-data">
    	<?php if( get_field('summary_section') ): ?>
    		<php while ( has_sub_field('summary_section') ): ?>
    			<div class='summary-data'>
    				<?php the_sub_field('bulletin_summary'); ?>
    				<?php the_sub_field('location'); ?>
    				<?php the_sub_field('report_number'); ?>
    				<?php the_sub_field('incident_date'); ?>
    				<?php the_sub_field('incident_time'); ?>
    			</div>
    		<php endwhile; ?>
    	<?php endif; ?>
    </div>
  • Figured it out!!

    I took a chance and made an if statement based on what I thought was the radio button type (turned out to be ‘choices’) and it actually worked.
    Here’s the code i used. So this calls all fields within a group, takes out any that doesn’t have a value, then puts an icon instead of a ‘yes or ‘no’ for the radio button, yet keeps all other fields loading like they normally do:

    
    $group_ID = 6817;
    $fields = array();
    $fields = apply_filters('acf/field_group/get_fields', $fields, $group_ID);
    if( $fields )
    {
      foreach( $fields as $field_name => $field )
      {
        $value = get_field( $field['name'] );
        if ($field['choices']){
          $map = array(
           'yes' => '<i class="icon-ok"></i>',
            'no' => '<i class="icon-remove"></i>'
           );
          $value = $map[ $value ];
        } else {
    
        }
    
        if( $value ) {
          echo '<li><b> ' . $field['label'] . '</b> ' . $value . '</li>';
      }
    }
  • I have the exact same issue. For me, there was no issue with the fields variable, but rather with the existence of the “sortable” method on the jQuery object at the point the mouseover is first called. I used the following workaround to overcome it:

    
        if('sortable' in $.fn) // The workaround
        {
          fields.addClass('sortable').sortable({
            update: function(event, ui){
              update_order_numbers();
            },
            handle: 'td.field_order'
          });
        }
    

    I think it’s a race condition with the jQuery UI sortable script

  • When I test the data, I get:

    
    <pre>string(93) "http://website.com/wp-content/uploads/sites/2/2013/09/1b8821.jpg" </pre>

    So it’s definitely recognizing the attachment id (I replaced the website URL with “website.com,” but the string it originally spit out is working.)

  • Ok I’ve worked out how to get the value in the link but how do I get the label

    <ul>					
    	<?php
    		$link = get_field('mt_web_fonts');
    		for($n=0; $n<count($link); $n++){
    			echo '<li>';
    			echo '<a href="'.$link[$n].'">label</a>';
    			echo '</li>';
    		}
    	?>
    </ul>
    
  • I’ve looked briefly into comparison operators and tried to get the below code to work with no success. New to PHP so be gentle :/

    <?php $client_id = get_currentuserinfo($user_ID); if ($client_id == get_field('user_select')) : ?>
    <p>Working</p>
    <?php else : ?>
    <p>Not Working</p>
    <?php endif; ?>
  • Hey Elliot,
    Sorry, I simplified that to make it easy to understand (but prob made it more confusing :B ). Here’s my full code:

    <?php
    	$args = array ( 'post_type' => 'school-category');             
    	$loop = new WP_Query( $args );
    	while ( $loop->have_posts() ) : $loop->the_post();
    ?>
    
    <div>
    
    <?php 
    
    	/* films is a realtionship ACF field */
    	$films = get_field('films');
    		
    	if( $films ): ?>
    	
    		<div class="image_data">
    		
    			<?php foreach( $films as $post): ?>
    				
    				<?php setup_postdata($post); ?>
    											
    				<?php if ( get_field('running_time') ) :
    					the_field('running_time');
    				endif; ?>
    				
    											
    				<?php if ( get_field('images') ) :
    					$images = get_field('images'); ?>
    					<img src="<?php echo $images[0]['url']; ?>" alt="<?php the_title(); ?>">
    				<?php endif; ?>
    									
    			<?php endforeach; ?>
    			
    		</div>
    		
    		<?php wp_reset_postdata(); ?>
    	
    	<?php endif; ?>
    
    </div>
    				
    <?php endwhile; ?>

    The issue is that the if (get_fields(‘images’)) returns a false, where as all over the rest of the site it returns true. I dumped all the post’s custom fields and could see that images was an empty array, where all the ACF fields returned their values.

    Any ideas? Thanks Elliot!

Viewing 25 results - 20,551 through 20,575 (of 21,337 total)