• Resolved debdstripe

    (@debdstripe)


    Have you gotten Post Duplicator to work with Task Lists & Invoices? ( Two add-ons of Customer Area? )

    Duplicate from the post list works for Files, Pages, Projects but not Task Lists or Invoices. If I go inside a Task List and click “Duplicate Task List” button in the Publish box, it WILL make a duplicate, but none of the tasks are duplicated – i.e it says “no tasks in this list”. I think Tasks and Task Lists are both CPTs, so I’m guessing that there is some relationship between Tasks & Task Lists that is not being copied properly.

    I tried a default theme and removing all plugins but Post Duplicator and WP Customer Area, no change.

    Wonder if the filter he mentioned here isn’t working on Tasks & Invoices??? Not sure…
    https://www.ads-software.com/support/topic/doesnt-work-for-private-custom-type-pages/?replies=5#post-7478285

    Side note, is there a way to set which CPTs you want to allow post duplication on? Conversations is also a CPT of WP Customer Area, and that doesn’t duplicate either, however, it would be better just to hide it there.

    Thanks much!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author metaphorcreations

    (@metaphorcreations)

    I’m not quite sure why this isn’t working as I have never used these add-ons. If tasks and task lists are separate custom post types then the duplicates are most likely not connecting due to a missing common post ID (probably for the task). I will need to contact the author of WP Customer Area to see if would give me a copy of these plugins so I can test.

    The filter I added in (from the previous ticket) was simply to add the duplicate button to the posts since he used a custom method of adding post action buttons. The actual duplicating functionality should work for any and all post types and custom meta… unless there is a custom implementation of custom meta or relationships.

    Currently, there isn’t any way to remove the duplicate button for specific post types. But, you can add your own custom css to hide the button for specific post types…. It’ll still be there, just not visible to the user.

    Plugin Author metaphorcreations

    (@metaphorcreations)

    @vprat (I’m not sure if this will notify you) could you please contact me to work out a way to test your extensions along with Post Duplicator?

    Thanks!

    Thread Starter debdstripe

    (@debdstripe)

    Thanks for getting back to me, I really appreciate your help on this. I just sent an email to @vprat as well, hopefully we can reach him.

    Hi,

    Sure, do not hesitate to contact me directly by email : you’ll find it on that contact page (not sure if I can directly post my email address here, looks like a previous message of mine got moderated)

    Thread Starter debdstripe

    (@debdstripe)

    Thanks @vprat! @metaphorcreations, let me know if you found his email address. Thanks again!

    Thread Starter debdstripe

    (@debdstripe)

    Just checking in on this. @metaphorcreations, did you get the files you needed from @vprat?

    Plugin Author metaphorcreations

    (@metaphorcreations)

    Yes, I received all the files. I will hopefully get a chance to look into this by the end of the week.

    Plugin Author metaphorcreations

    (@metaphorcreations)

    Ok, I have figured out how to resolve this issue. I have made some updates to my plugin but to get it fully functioning @vprat will need to update his files as well.

    The actual tasks are their own post type attached to the task list as a child post. So, to get the tasks duplicated each task post also needs to be duplicated and then modified to attach the duplicated task list is it’s parent post.

    I realized as I was working on this that I cannot support customizing my file for special situations like this (it could get out of hand). But, I have now added a custom action into my plugin (after the duplication process). I have also separated out the post duplication function from the ajax call used when clicking a Duplicate button. This allows posts to be duplicated by other means based on the situation (like the code below).

    I will update my plugin soon, to version 2.20. I have worked the necessary code to be used in the Task extension to successfully duplicate tasks with the task list. @vprat will need to add the following into the extension (feel free to modify if you wish):

    function my_post_duplicator_created( $original_id, $duplicate_id ) {
    	
    	if( get_post_type($original_id) != 'cuar_tasklist' || get_post_type($duplicate_id) != 'cuar_tasklist' ) return;
    	
    	// Get & loop through the original tasks
      $tasks = get_posts(array(
    	  'post_type'   => 'cuar_task',
    	  'post_parent' => $original_id
      ));
      
      if( is_array($tasks) && count($tasks) > 0 ) {
      	foreach( $tasks as $i=>$task ) {
    	  	
    	  	// Duplicate the task
      		$duplicate_task_id = mtphr_duplicate_post( $task->ID );
      		
      		// Update the post parent of the task
      		wp_update_post(
    		    array(
    	        'ID' => $duplicate_task_id, 
    	        'post_parent' => $duplicate_id
    		    )
    			);
      	}
      }
    	
    }
    add_action( 'mtphr_post_duplicator_created', 'my_post_duplicator_created', 10, 2 );

    I have not looked into the Invoices duplication, but I’m assuming it’s a similar situation that can be worked out in a similar fashion (using the mtphr_post_duplicator_created hook).

    @vprat I will leave the custom post/page row actions (for the duplicate button) that I had previously built into the plugin. But, I have also modified the button output into a separate function to be easily used in other custom situations like this. Here is how I would add it to your plugin (if I didn’t already have it included in my plugin):

    function mtphr_post_duplicator_action_row( $actions, $post ){
    	if( function_exists('mtphr_post_duplicator_action_row_link') ) {
    		$actions['duplicate_post'] = mtphr_post_duplicator_action_row_link( $post );
    	}
    	return $actions;
    }
    add_filter( 'cuar/core/admin/content-list-table/row-actions', 'my_post_duplicator_action_row', 10, 2 );
    Thread Starter debdstripe

    (@debdstripe)

    This is great, thank you so much. As I understand it, WP Customer Area will need to be edited for your fixes to work, correct? Also, when do you expect to release 2.20? Just want to make sure I check for the update on the correct day. Thanks again!!

    Thread Starter debdstripe

    (@debdstripe)

    Hello! I updated to 2.20 and WP Customer Area 7.1.5.

    Task Lists are duplicating better, but the tasks are not copying to the duplicated Task List still. You mentioned something that needed to be edited in WP Customer Area… @vprat emailed me and said that you two talked and that you were to be the only person on this to maintain compatibility and/or that you may release a WPCA add-on.

    Just curious what I need to do to get the tasks within a task list to duplicate. Should I add your my_post_duplicator_created function to my functions.php for now?

    Thanks much!

    • This reply was modified 8 years, 1 month ago by debdstripe.
    • This reply was modified 8 years, 1 month ago by debdstripe.
    Thread Starter debdstripe

    (@debdstripe)

    For anyone out there reading this thread… I added his function above: “my_post_duplicator_created” to functions.php and Task Lists are duplicating properly now.

    Thread Starter debdstripe

    (@debdstripe)

    Just a note, if you want tasks duplicated in order, a couple of updates to the function:

    function my_post_duplicator_created( $original_id, $duplicate_id ) {
    	
    	if( get_post_type($original_id) != 'cuar_tasklist' || get_post_type($duplicate_id) != 'cuar_tasklist' ) return;
    	
    	// Get & loop through the original tasks
      $tasks = get_posts(array(
    	  'post_type'   => 'cuar_task',
    	  'post_parent' => $original_id,
              'numberposts' => -1,       //add all posts
              'orderby' => 'menu_order'  //add orderby
      ));
      
      if( is_array($tasks) && count($tasks) > 0 ) { 
      	foreach( $tasks as $i=>$task ) {
    	  	
    	  	// Duplicate the task
      		$duplicate_task_id = mtphr_duplicate_post( $task->ID );
      		
      		// Update the post parent of the task
      		wp_update_post(
    		    array(
    	        'ID' => $duplicate_task_id, 
    	        'post_parent' => $duplicate_id
    		    )
    			);
      	}
      }
    	
    }
    add_action( 'mtphr_post_duplicator_created', 'my_post_duplicator_created', 10, 2 );
    • This reply was modified 8 years, 1 month ago by debdstripe.
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘WP Customer Area – Task Lists & Invoices’ is closed to new replies.