Support

Account

Forum Replies Created

  • Had the same problem on a project I’m working on where subcribers / contributor’s are using the ACF_Form() to create new posts and also to upload images through the gallery field.

    The problem occurs with current_user_can(‘edit_post’, $post_id ) returns false (this is checked when the user tries to upload an image through the media uploader ) if the post isn’t already created….so while using the form..you first want to create the post..and THEN let the user upload images through the gallery field. This worked for me… not the perfect sollution…anyone else have a better one, please let me know 🙂

  • This would be a great addition.

  • Was just about to post a similar request myself. I’m missing atleast a more flexible way of styling the form.

    Having to use javascript and lots of !important’s to override current styling, is a real pain… Hope this will be a feature in a near future 🙂

  • Piojos: I’ve updated the above code. It should now display all custom posts. I have not testet the code though.. But I guess you get the point when you have a look at it. You might wanna add some kind of seperator or alternate display method to show the post types which the posts belong to.

  • Created a workaround for this by adding a new selection called “custom post types”

    If anyone else need it, or have a suggestion on how to improve it, feel free to hollar 🙂

    add_filter('acf/location/rule_types', 'acf_location_rules_types');
    function acf_location_rules_types( $choices )
    {
        $choices['Custom Post types']['cpt_parent'] = 'Custom post type parent';
     
        return $choices;
    }
    add_filter('acf/location/rule_values/cpt_parent', 'acf_location_rules_values_cpt_parent');
    function acf_location_rules_values_cpt_parent( $choices )
    {
    	$args = array(
    		'hierarchical' => true,
    		'_builtin' => false
    	);
        $posttypes = get_post_types( $args );
     
        if( $posttypes )
        {
            foreach( $posttypes as $posttype ):
            
    if( $posttype != 'acf' ):
    $args = array(
    'post_type' => $posttype,
    'posts_per_page' => -1,
    'post_status' => 'publish'
    );
    $customposts = get_posts( $args );  
    if ( $customposts  ) {
    foreach( $customposts as $custompost ){
    $choices[ $custompost->ID] = $custompost->post_title;
    }
    }
    endif;
            endforeach;
        }
     
        return $choices;
    }
Viewing 5 posts - 1 through 5 (of 5 total)