Support

Account

Home Forums Front-end Issues Outputting ACF Form from a shortcode in WYSIWYG editor Reply To: Outputting ACF Form from a shortcode in WYSIWYG editor

  • The problem is that ACF outputs the form when the shortcode is run and what you need it to do is return the value. To do this you use a PHP output buffer

    
    // before you generate form
    ob_start();
    	
    	$current_id = get_current_user_id();
    	$user_id = 'user_' . $current_id;	
    	
    	$options = array(
    	    'post_id' => $user_id,
    	    /* my field group grabs unit, home phone, and cell phone acf */
    	    'field_groups' => array('3307', ),
    	    'submit_value' => 'Update' 
    	);
    	acf_form( $options );
    
    // after your code
    $form = ob_get_clean();
    return $form;