Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Sebastian

Hook to inline edit

Hi there,

I try to do the following. I have a CPT with a hidden title field when editing the title, but the title is programmatically set on save and update (uses value of a ACF field to set the title).

Everything works fine, (I use the ‘wp_insert_post_data’ filter to modify the title), except from inline editing. When I edit the relevant ACF field using inline editing, the title is not being updated.

Is there any hook I can use when using inline editing of a ACF field to update the title?

Best regards,
Sebastian

9 years, 2 months ago
Tobias Schutter
Developer

Hi Sebastian,

We have an action cac/inline-edit/after_ajax_column_save in place that is triggered after you have used inline edit as a user. You should be able to run your custom code on that.

The action cac/inline-edit/after_ajax_column_save is located in /classes/inline-edit/classes/model.php.

I will add an example to the documentation.

Best,

Tobias

9 years, 2 months ago
Frank

Hi,

Change the hook cac/inline-edit/after_ajax_column_save with ac/columns_stored since v4 but the examples on https://www.admincolumns.com/documentation/developer-docs/action-reference/cacinline-editafter_ajax_column_save/ aren’t working anymore.

Here’s the code:

function my_cac_after_title_save_update_custom_field( $column, $id, $value, $editable_model_object ) {

    // only applies when the column type is a 'title' and is from the post type 'page'
    if ( 'title' === $column->get_type() && 'dossiers' == $column->get_post_type() ) {

        // update another custom field
        update_post_meta( $id, 'client', $value );
    }
}
add_action( 'ac/columns_stored', 'my_cac_after_title_save_update_custom_field', 10, 4 );

Did I miss something ?

6 years, 9 months ago
Stefan van den Dungen Gronovius
Developer

Hi Frank,

The correct action that is triggered after the value is saved is do_action( 'acp/editing/saved', $column, $id, $value );

As you can see, the last param is not available anymore so you can change your code to something like this (not tested):

/**
 * @param AC_Column $column
 * @param int $id
 * @param mixed $value
 */
function my_cac_after_title_save_update_custom_field( $column, $id, $value ) {

	// only applies when the column type is a 'title' and is from the post type 'page'
	if ( 'title' === $column->get_type() && 'dossiers' == $column->get_post_type() ) {

		// update another custom field
		update_post_meta( $id, 'client', $value );
	}
}
add_action( 'acp/editing/saved', 'my_cac_after_title_save_update_custom_field', 10, 3 );
6 years, 9 months ago
Frank

Hi Stefan,

Thanks for your message! Will try this back to the office.

Have a great day,

Frank

6 years, 9 months ago
Philipp

unfortunately the support staff seem to be in vacations and i was struggling with a lot of php errors when i tried to use the code from the faq. so this is my code with recent acp and acf addon:

// we need to connect our region function to acp inline function
function my_cac_after_title_save_update_custom_field( $column, $id, $value ) {
    if ( $column->get_post_type() === "host" && $column->get_type() == "column-acf_field" ) {
        if($column->get_meta_key() === "region") set_region($id);
    }
}
add_action( 'acp/editing/saved', 'my_cac_after_title_save_update_custom_field', 10, 3 );

first i tried to only use the if statement $column->get_meta_key() but this returned a fatal error when i also added inline editing for taxonomy field in the same view. therefore i needed to check for acf_field first!

6 years, 7 months ago
Tobias Schutter
Developer

Hi Philipp,

The fatal error happened because the AC_Column class does not have a get_meta_key() method. Only the AC_Column_Meta column has this specific method. It’s best to do either an instanceof check or checking the column type (like you did).

I added another example to our documentation with a similar use case to yours. You can use that as a reference next time.

Cheers, Tobias

p.s.: we do have a team member on vacation, but you should still get a reply within a business day

6 years, 7 months ago
Brad Gregory

Seems the links now just drop you into the placeholder for hooks and actions. @TOBIAS – can we still hook into inline edit save?

3 months, 2 weeks ago

You must be logged in to reply to this topic.