Support

Account

Forum Replies Created

  • Have you updated plugins recently? There was some weird stuff going on between the transition of ACF 3 and 4, this sounds similar to some problems I experienced, but that was weeks (if not months) ago. Have you tried re-installing ACF and its addons?

  • Does the filter fire when it’s not wrapped in the if (bbp_is_single_user_edit())? I would also be interested in the filter priority order and whether you’re calling before or after any other filters.

  • there could be a variety of things slowing your site down. I usually start troubleshooting with the theme:

    • Change to a default theme (TwentyEleven, TwentyTwelve) and see if it gets faster
    • Try running Google PageSpeed tools
    • In Firefox or Chrome, open the developer tools (F12) and change to the Network tab (Chrome) or Net tab (Firefox)… watch for slow-loading javascripts or images. Also check for errors while you’re here.
    • Install a caching plugin like BWP Minify
    • Check out the WP Debug Bar for some query information

    I have never had ACF slow my site down on its own, and I have made sites with dozens of custom fields. Let us know what you find!

  • Assuming that you have the complete string Field : ABC|DEF|GHI|JKL|MNO:

    
    $data = explode( ':', get_field('MyField' );
    $parts = explode( '|', $data[1] );
    foreach($parts as $k=>$part){
        if($k && ($k < count($parts) ) ) echo ' / ';
        echo $part;
    }
    

    … but if your field string is only ABC|DEF|GHI|JKL|MNO, you can leave out the first explode step:

    
    $parts = explode( '|', get_field('MyField' );
    foreach($parts as $k=>$part){
        if($k && ($k < count($parts) ) ) echo ' / ';
        echo $part;
    }
    
  • Can you provide a sample of the get_field('fieldname'); data? Here’s a quick debug snippet to see what the field holds:

    echo '<pre>'.print_r(get_field('fieldname'), true).'</pre>';

    If you already have a comma-separated value and want to convert it to an array, try this little snippet out:

    
    $values = explode(',', get_field('fieldname'));
    if( count($values)){
        foreach($values as $value){
            echo trim($value);
        }
    }
    

    This snippet should work with a text string that looks something like one,two, three four, five-, six and should output this: onetwothreefourfivesix.

    However, I have a feeling that you already have an array as provided by get_field('fieldname'), so if that’s the case then you don’t need to explode at all, just loop with a foreach() and output with something like echo $value.', ';. A snippet like this might look like:

    
    $values = get_field('fieldname&#039);
    if( count($values)){
        foreach($values as $k=>$value){
            if($k) echo ', ';
            echo $value;
        }
    }
    

    In this example, $k is a counter that lets us know what item number we are currently working with. During the first loop, $k will be 0 so no comma will be printed.

  • Hi again @flashpunk! I dug into my local MU setup and confirmed how ACF operates across MU sites.

    The attached screenshot details a 4-site MU setup, and the primary site has a single post with a single text ACF with the contents “derp” in it. As we can see from the database queries on the right, the string was only found in the primary MU install site and not the others… so I guess this confirms the idea that ACF data is independent across MU sites.

    You’ve undoubtedly already checked this out, but can we confirm that the missing slider button text actually exists from the admin? Have you tried deleting that particular ACF field and re-creating it and adding the text again?

    Debugging without code/db access is indeed a bit harder 🙂

  • Interesting thought @drrobotnik, but I’m not sure that the application is the same as in Gravity Forms. It does make sense to start with a class add-on and work up, but this thread was started with the admin view / post edit pages in mind instead of the theme side. Usually when I work with ACF in a theme, I display the fields as needed and don’t rely on formatting at all.

    This is definitely an issue that Gravity Forms struggles with as well though – editing forms gets to be annoying once they move past page break.

    If a class is added and used within the administration edit pages, there’s no reason that it can’t also be added to the field object and retrieved in the theme. Since field data can be retrieved with get_field() etc, maybe it would make sense to have layout data available as well!

    Do you guys think we should be writing this as a standalone ACF plugin?

  • Well then… do you have access to the databases? I’m not terribly familiar with MU setup, but I do seem to recall that the original database gets cloned and set up for each new site.

    I’m checking out a test install of MU right now, but maybe you can answer faster – are the same custom fields available across all of the MU sites in the admin section, and is it possible to set up a new field in one MU site and not have it visible in a different site? If yes, it might be a good idea to check all of the MU sites and make sure that they all have the same fields… and then go and re-save/update the sliders and their text values.

  • Hah, yes that is always challenging.

    Ah, you say you added that particular field later in development… was that before or after the WPMU setup? I wonder if the databases aren’t exactly the same.

  • It would be interesting to see if the data is actually being loaded into the slide object.

    Debug! Commented / hidden dump:

    <?php echo 'ID: '.$post->ID.'<!-- '.print_r($slider, true).' -->'; ?>

    … or wide-open visibility:

    <?php echo '<pre>ID: '.$post->ID.' - '.print_r($slider, true).'</pre>'; ?>

    2 uses here: confirm that $post->ID is the one that we need, and dump all of the $slider data into a visible array. is [slide_button_text] being populated where it should?

    Troubleshooting suggestions from the bottom up I guess. Oh, and place those after you load the $slider object, obviously 😀

  • Out of curiosity, have you checked your error logs recently? Sometimes there’s treasure in there.

    That’s a pretty strange bug! The first thing that pops to mind is that the post loop is using a global $post variable that you’re not expecting, but that is obviously not the case – the rest of the slide info seems to be showing!

    Can we assume that $slide = get_field('slider', $post->ID); or something similar? And are you using two different sets of code, or is the PHP/MySQL just being served to 2 different URLs?

  • Oh, and just in case you were interested: PSD! Don’t make fun of my terrible skills XD

  • The image here uses a random glyph icon set, AmandaB’s field layout and a Bootstrap popover. This is by no means the best solution, it’s just an idea!

    Visualization suggestion: when fields are hovered on, a small arrow icon might appear in the corner. On clicking this icon, a menu could be displayed with field-specific layout options.

    After the “Expand Field” or “Contract Field” link is clicked, the field wrapper could have its column width class adjusted to the next closest division – if we were using a 12-col class-based grid system, a field with class="field six columns" might instead become class="field seven columns" on click. This might be a bit easier on the Javascript/English translation if a more custom integer-based system was used, for example: class="field col6 columns"… this would allow for JS string split and integer manipulation, which is a bit less tedious 🙂

    Clearly this is only display-side, I imagine that admins would like the ability to specify layout options like this from the field edit page at /wp-admin/edit.php?post_type=acf as well.

    Data submission could either be AJAX on popover link click, or it could be submitted on post update like normal – the latter may be better in case users change layout and decide to refresh the page in order to revert changes.

    I suppose this means adding more data for each field – ACF will need to keep track of each field’s layout settings behind the scenes. I’m not sure where exactly this data should be placed however… it’s not particularly useful in the theme-side get_field() calls, so in the interest of efficiency it might be better to only have this info available in the administration pages.

    The downside of the display-side layout adjustment is that it will need to be role-restricted. We won’t want everybody to be changing field layouts on a whim! I’m not sure what capability level is required to add/edit ACF fields, but I would assume that it’s manage_options – the same capability level could be used to determine whether a user has the ability to adjust field layout on the fly.

    Thoughts?

  • You betcha! If you check out the “Forum Topics Started” page for a user ( /forums/users/emcniece/topics/ in my case ) we can see the title of the topic, the number of comments, the forum that the topic is placed within, and the last reply time along with the fancy circle status indicator. Since the title of the topic links directly to the full topic view, it’s easy to access these forum topics.

    When users are on the “Replies Created” page ( /forums/users/emcniece/replies/ in my case) there is no link to the parent topic – it only shows the user avatar, user name, timestamp and reply text. There does not seem to be any convenient method of jumping to the full thread that each reply belongs to!

    Do you think it would be a good idea to place a topic link in the “Forum Replies Created” page for each of the replies listed so that we can easily jump to each particular topic?

  • What do you think about adapting a grid system to fit these fields? Maybe an expand/shrink icon in the corner of each field to allow width adjustment?

  • Thanks AmandaB, I was really hoping it didn’t come down to that ;). I see that you’re using tabs as well – I think we’ll just stick with that for now.

  • A quick snippet for you:

    add_action( 'pre_get_posts', 'filtre');
    function filtre($query) {
       //echo '<pre>'.print_r($query->query_vars['post_type'], true).'</pre>';
    
        switch($query->query_vars['post_type']){
    
            
            case 'attachment':  // Media library
                if( current_user_can('manage_own_media') ) $query->set('author', get_current_user_id() );
                break;
            
            case 'post':        // Posts
                if( current_user_can('manage_own_posts') ) $query->set('author', get_current_user_id() );
                break;
    
            case 'page':        // Pages
                if( current_user_can('manage_own_pages') ) $query->set('author', get_current_user_id() );
                break; 
                
       } // switch post_type
        
        return $query;
    }

    Of course this is assuming that there are custom permissions set up using the User Role Editor!

  • Awesome! Don’t forget that you can make your own permission checks with http://wordpress.org/plugins/user-role-editor/&#8230; so instead of checking for current_user_can('level_5') you could do something like current_user_can('browse_media') – and then you can assign that permission to any role you wish!

  • Wow, no kidding… I’ve had my fair share of those, that’s for sure. Good to hear that you made some progress! Filtering works properly now?

  • Seems to work for me, let’s keep troubleshooting! Have you tried entering user ID numbers directly into the $current_user->id and get_current_user_id() locations?

  • As previously stated! /wp-admin/edit.php?post_type=acf&page=acf-export

Viewing 25 posts - 51 through 75 (of 80 total)