
Hi @youngwolf0
Your code looks perfect, so for that great work.
Your next step is to debug the function to find out at what line it is failing.
Firstly, turn on DEBUG MODE in your wp-config.php file and then use a simple script like so to test that your loop is working:
<?php
$user = "user_" . $member->ID;
echo '<pre>';
print_r( $user );
echo '</pre>';
?>

Hi @figureone
I had previously used that code (that is why it is commented out).
I had to remove it due to multiple issues on many servers.
Although the code makes logical sense, it did not work across all servers and many WYSIWYG started double escaping or even removing completely special characters.
I’m not confident enough to put this back in, and I do apologies that this doesn’t leave you with much option, but perhaps you could chat to your server and change your magic quotes setting?
Thanks
E

Hi @hummelmose
Thanks for the clarification. This is how I would do it.
Add an action to the wp action. This action is run when WP is ready to function.
Look at the URL (find the url in the $_SERVER array) and check if the url follows your above pattern. You can check for a patern with regexp.
After the matching is done and you have a variable holding the $article_id, your next step is to find the post that has a matching custom field value.
You can query the WP posts with teh get_posts function as shown here:
http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/
Then, once you have the $post object, you can redirect to it like so:
wp_redirect( get_permalink( $post->ID ) );
exit;
I hope the above makes sense. You may need to get some help from a PHP / WP dev if you can’t get it to work.
Good luck mate.
Cheers
E
I actually ended up coding a basic importer that was quite specific to our csv. It does allow for mapping CSV headers against ACF fields, but it isn’t particularly elegant or completely reliable right now. I learned quite a bit whilst doing it and will hopefully be going back to produce something more robust, I think ACF could do with it!
Sorry about that; I think even I was confused on what I wanted to do…
The code below gave me what I wanted; I’m always open to tips on optimizing it further.
<?php if(get_field('choose_layout') == "1col")
{ ?>
<p><?php the_field('single_column'); ?></p>
<?php } elseif (get_field('choose_layout') == "2col")
{ ?>
<p><?php the_field('two_columns_left'); ?></p>
<p><?php the_field('two_columns_right'); ?></p>
<?php } elseif (get_field('choose_layout') == "3col")
{ ?>
<p><?php the_field('three_columns_left'); ?></p>
<p><?php the_field('three_columns_middle'); ?></p>
<p><?php the_field('three_columns_right'); ?></p>
<?php } ?>
hi Elliot.
we are trying to change it but still it wont work
can you tell me how to change it?
the php code is.
<?php
/*
* Template Name: Onze scholen
*/
?>
<?php get_header(); ?>
<div class="slider-divider"></div>
<div class="wrapper">
<div class="content">
<div class="main-content">
<h1><?php the_title(); ?></h1>
<ul>
<?php if(get_field('scholen')): ?>
<ul>
<?php while(has_sub_field('scholen')): ?>
<li><img src="<?php the_sub_field('school-afbeelding'); ?>" width="200"; alt="" />
<?php the_sub_field('school-naam'); ?></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
I wrote the following function and call and placed them in the active themes functions.php file:
set_legacy_members(1);
function set_legacy_members($members_value) {
$members = get_users();
$is_member = 'field_522f3c55f16be';
foreach ($members as $member) {
$user = "user_" . $member->ID;
update_field($is_member, $members_value, $user);
}
}
However this hasn’t worked, the field is still set to false for every member, what am I doing wrong?

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 @studiogulo
This has already been documented here:
http://www.advancedcustomfields.com/resources/tutorials/querying-relationship-fields/
Thanks
E

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!

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!
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
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.