Support

Account

Forum Replies Created

  • James, I removed the ACF: Font Awesome plugin and the Field. Now I only have a URL field within the Repeater Field and the problem still exists. I can delete all existing rows except for the last one.

    I created a GIF showing the error (also attached): https://cl.ly/3l2K0V2C0Q0p

  • James, I tested on a new WP install and the TwentySixteen theme. I am still having this problem. Do you think the problem might be with the ACF: Font Awesome plugin?

  • Sure. I’m working on it now and will let you know what I come up with.

    Attached is the JSON file.

    Thanks

  • After deleting the other Page Link fields and Adding New Page Link fields, I can now filter by Post Type for all fields. I think the problem (or bug) was from duplicating the Page Link field.

  • I’m not exactly sure how this is done, but you might be able to if you check for a specific field ID or Key within the form you targeting.

    if($field['id'] == 'field_xxxxxxxxxxx') {
        // execute your code
    }
  • Here’s another why to do this:

    add_filter('acf_the_content', 'shortcode_empty_paragraph_fix');
    function shortcode_empty_paragraph_fix($content) {   
    	$array = array (
    		'<p>[' => '[', 
    		']</p>' => ']', 
    		']<br />' => ']'
    	);
    
    	$content = strtr($content, $array);
    
    	return $content;
    }
  • I found a solution to my problem. I ended up using the wpmu_new_blog action hook to update the post meta when a new blog is created.

    Here is a basic idea of the code used:

    add_action('wpmu_new_blog', 'katart_update_new_blog', 10, 2);
    function katart_update_new_blog($blog_id,$user_id) {
       switch_to_blog($blog_id);
    
       $admin = get_userdata( $user_id );
    
       update_post_meta( 4, 'custom_post_meta', $admin->custom_user_meta );
    
       restore_current_blog();
    }

    This was a unique situation where I know the post ID. I hope this helps someone.

  • I’ve decided to come at this from a different angle and found a solution. All I need to save is the Post Title and Post Content which is really simple to do with v5 acf_form. But I want to use a “Basic” wysiwyg editor and remove the ability to upload media.

    Here is the solution I came up with

    Here is the code on the Create Post page template:

    acf_form( array(
    	'post_id' => 'new_post',
    	'new_post' => array(
    		'post_status' => 'publish',
    		'post_type' => 'post',
    		'post_title' => $_POST['acf']['_post_title']
    	),
    	'post_title' => true,
    	'post_content' => true,
    	'submit_value' => __('Publish', 'ppt-church'),
    	'updated_message' => __('Your post has been published', 'ppt-church')
    ));

    Here is the code on the Edit Post page template:

    $post_id = $_GET['post_id'];
    acf_form( array(
    	'post_id' => $post_id,
    	'post_title' => true,
    	'post_content' => true,
    	'submit_value' => __('Update Post', 'ppt-church'),
    	'updated_message' => __('Your post has updated', 'ppt-church')
    ));

    I use $_GET to get the post ID from the URL

    Here is the code in the functions.php file:

    // Change Post Content Type
    add_filter( 'acf/get_valid_field', 'change_post_content_type');
    function change_post_content_type( $field ) {
    		
    	if($field['type'] == 'wysiwyg') {
    		$field['tabs'] = 'visual';
    		$field['toolbar'] = 'basic';
    		$field['media_upload'] = 0;
    	}
    		
    	return $field;
    		
    }

    I hope this helps anyone

  • I just found the solution to my problem. Here is the working code:

    // Change Post Content Type
    add_filter( 'acf/get_valid_field', 'change_post_content_type');
    function change_post_content_type( $field ) {
    		
    	if($field['type'] == 'wysiwyg') {
    		$field['tabs'] = 'visual';
    		$field['toolbar'] = 'basic';
    		$field['media_upload'] = 0;
    	}
    		
    	return $field;
    		
    }
  • I just found a solution to my problem. Here is the working code:

    // Change Post Content Type
    add_filter( 'acf/get_valid_field', 'change_post_content_type');
    function change_post_content_type( $field ) {
    		
    	if($field['type'] == 'wysiwyg') {
    		$field['tabs'] = 'visual';
    		$field['toolbar'] = 'basic';
    		$field['media_upload'] = 0;
    	}
    		
    	return $field;
    		
    }
  • @JiveDig Thanks for the reply. I’m rethinking my needs for this project. All I need to save is the Post Title and Post Content which is really simple to do with v5 acf_form. What I want is to use a “Basic” wysiwyg editor and remove the ability to upload media.

    Based on This Post, it looks as it might be possible using the acf/get_valid_field or acf/get_valid_field/type= functions.

    Even though the following code is not valid, this is my thought process:

    if( $field['type'] == 'wysiwyg' ) {
        $this->defaults = array(
            'toolbar' => 'basic',
            'media_upload' => 0 
        )
    }

    Any ideas?

  • @passatgt This is a great solution for the labels, but here is a different twist to this. Is it possible to change the WYSIWYG Editor to basic and media upload to false?

    if( $field['type'] == 'wysiwyg' ) {
        $this->defaults = array(
            'toolbar' => 'basic',
            'media_upload' => 0 
        )
    }

    I know this is not working code but it’s the idea I’m looking for. Any ideas?

  • @JiveDig Is it possible to use the same acf/pre_save_post filter for 2 acf_form that are on 2 different page templates? I can create a new post but I can’t Edit an existing post. You can see my question here: http://support.advancedcustomfields.com/forums/topic/acf_form-not-creating-new-post/

    The Edit Post page loads the ACF Fields but the update only updates the ACF Fields and does not edit the Post Title and Post Content.

    Any ideas how to fix this?

  • I resolved my problem by changing the fields name from ['fields'] to ['acf']

    The problem I am having now is editing a post. Here is the code in the functions.php file:

    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
    function my_pre_save_post( $post_id ) {
      	
    	if( $post_id != 'new_post' ) {
    		return $post_id;
    	}
      
        $post = array(
            'post_status'  => 'publish',
    	   'post_title'  =>  $_POST['acf']['field_54e6020d07a17'],
    	   'post_content'  =>  $_POST['acf']['field_54db8cd72d3c2'],
            'post_type'  => 'post' ,
        ); 
      
        $post_id = wp_insert_post( $post );
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] ); 
      
        return $post_id;
    }

    Here is the acf_form on the Add Post page template:

    acf_form( array(
    	'post_id' => 'new_post',
    	'fields' => array( 'field_54e6020d07a17', 'field_54db8cd72d3c2' ),
    	'updated_message' => 'Post Created'
    ));

    Here is the acf_form on the Edit Post page template:

    acf_form( array(
    	'post_id'	=> $_GET['post_id'],
    	'fields' => array( 'field_54e6020d07a17', 'field_54db8cd72d3c2' ),
    	'submit_value'	=> 'Update the post!'
    ));

    Can anyone help me figure this one out? Thanks

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