Support

Account

Home Forums Front-end Issues acf_form() Frontend wp uploader not visible to users

Solved

acf_form() Frontend wp uploader not visible to users

  • I’ve noticed that when using acf_form() to create a frontend form, only logged in admins can see the wp uploader. Other users only see the basic uploader. I’d like for users to see the wp uploader as well.

    I am using the Ultimate Member plugin. I think that is the culprit here. I have tried many different combinations of user type settings within ultimate member. I’m hoping someone has run into this issue before and resolved it.

    Here is the code:

    <?php
    /**
     * Template Name: New Property
     *
     */
     
    /**
     * Add required acf_form_head() function to head of page
     * @uses Advanced Custom Fields Pro
     */
     
    if (!(is_user_logged_in() || current_user_can('agent'))) {
    	wp_redirect( home_url() ); exit;
    }
    
    /**
     * Deregister the admin styles outputted when using acf_form
     */
    add_action( 'wp_print_styles', 'deregister_admin_styles', 999 );
    function deregister_admin_styles() {
    	wp_deregister_style( 'wp-admin' );
    }
    
    /**
     * Add ACF form for front end posting
     * @uses Advanced Custom Fields Pro
     */
    add_action( 'the_content', 'do_create_post_form' );
    function do_create_post_form() {
    	$new_post = array(
    		'post_id'            => 'new', // Create a new post
    		'field_groups'       => array(41,58), // Create post field group ID(s)
    		'form'               => true,
    		'return'             => '%post_url%', // Redirect to new post url
    		'html_before_fields' => '',
    		'html_after_fields'  => '',
    		'uploader'			 => 'wp',
    		'submit_value'       => 'Create Property'
    	);
    	acf_form_head();
    	acf_form( $new_post );
    }
    /**
     * Back-end creation of new candidate post
     * @uses Advanced Custom Fields Pro
     */
    add_filter('acf/pre_save_post' , 'do_pre_save_post' );
    function do_pre_save_post( $post_id ) {
    	// check if this is to be a new post
    	if( $post_id != 'new' ) {
    		return $post_id;
    	}
    	// Create a new post
    	$post = array(
    		'post_type'     => 'property', // Your post type ( post, page, custom post type )
    		'post_status'   => 'publish', // (publish, draft, private, etc.)
    		'post_title'    => wp_strip_all_tags($_POST['acf']['field_564267b53d934']), // Post Title ACF field key
    		'post_content'  => $_POST['acf']['field_5642694a3d935'], // Post Content ACF field key
    	);
    	// insert the post
    	$post_id = wp_insert_post( $post );
    	// Save the fields to the post
    	//do_action( 'acf/save_post' , $post_id );
    	
    	return $post_id;
    }
    
    get_header(); 
    ?>
    			
    			<div id="content">
    
    				<div id="inner-content" class="row">
    			
    					<div id="main" class="large-12 medium-12 columns first" role="main">
    					
    					    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    					
    					    	<?php get_template_part( 'parts/loop', 'single' ); ?>
    					    	
    					    <?php endwhile; else : ?>
    					
    					   		<?php get_template_part( 'parts/content', 'missing' ); ?>
    
    					    <?php endif; ?>
    			
    					</div> <!-- end #main -->
        
    					<?php //get_sidebar(); ?>
    
    				</div> <!-- end #inner-content -->
        
    			</div> <!-- end #content -->
    
    <?php get_footer('blank');
  • Actually, the problem is that only those user types that have access to management of the media library in WP will see the more than the basic uploader.

    This is a WP security feature that is not related to ACF or the other plugin you mention. In order for users to see the same thing that the admin uses you need give them the permissions to do so. I am not familiar with the plugin you mention, but it requires giving them the permission to edit posts and upload files, and possibly other things as well. Basically you need to give them all most of the permissions that an “Editor” has.

  • This reply has been marked as private.
  • You might try this plugin, it’s the one I use, https://wordpress.org/plugins/user-role-editor/. It might let you test faster.

    I’d also log in using two different browsers, one as the admin and in the other browser as a user of the other user type, that way I could test different permission combinations without needing to log out and back in each time.

  • That plugin did the trick. I guess the capabilities I listed were incomplete or incompatible with each other. In any case, you were right, this was a user permissions issue. Thanks for the help. Happy Holidays!

  • You could have associated any role to new created member, not just subscriber.
    This solves the permission issue without additional plugin.

  • I’m currently running the acf_form for guests, but the guest uploader does not work.

    What should I do?

  • see the comments already posted in this topic.

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

The topic ‘acf_form() Frontend wp uploader not visible to users’ is closed to new replies.