admin管理员组

文章数量:1307827

Trying to run the same function for multiple actions. I've got it working for ACF, but the Admin Columns action has a class, and I think that's where I'm struggling, though I'm not sure.

//Works:
function acp_editing_saved_usage28( AC\Column $column, $post_id, $value ) {
    if ( get_post_type( $post_id ) == 'vbrands-products' ) {
        update_field( 'field_5ff7af3315c5b', 'hoop', $post_id);
    }
}

add_action( 'acp/editing/saved', 'acp_editing_saved_usage28', 10, 3 );

//Does not work, but should:
function testfunction(){
    if ( get_post_type( $post_id ) == 'vbrands-products' ) {
        update_field( 'field_5ff7af3315c5b', 'tedsssst', $post_id); 
    }   
}

function acp_editing_saved_usage28( AC\Column $column, $post_id, $value ) {
    testfunction();
}
add_action( 'acp/editing/saved', 'acp_editing_saved_usage28', 10, 3 );

//However, this does work with ACF and the following code using the same testfunction() from above:
function my_acf_save_post88( $post_id ) {
    testfunction();
}
add_action('acf/save_post', 'my_acf_save_post88');

本文标签: Issue passing action class to nested function Admin Columns