• Resolved dawiyo

    (@dawiyo)


    In my CPT (media_query), I have 2 ACF fields called Organization and Organization (Common). I have no issues using CAC to get the values (if there are any) to display in the table. What I need to do is if “Organization” is empty, and “Organization (Common)” has a value, then overwrite “Organization” with the value from “Organization (Common)”. My PHP isn’t the greatest but I’m having trouble with the code below.

    function myplugin_cac_column_featured_image_value( $value, $postid, $column, $post_type ) {
    
    	// Organization (Common) Column
    	if ( $column->properties->name == 'column-meta-6' && $value ) {
    		$org_common = $value;
    	}
    
    	// Organization Column
    	if ( $column->properties->name == 'column-meta-5' && !$value ) {
    		$value = $org_common;
    	}
    
    	return $value;
    }
    add_filter( 'cac/column/value', 'myplugin_cac_column_featured_image_value', 10, 4 );

    Any suggestions?

    https://www.ads-software.com/plugins/codepress-admin-columns/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jesper van Engelen

    (@engelen)

    Unfortunately, there is currently no way to exchange information between columns that way. What you could do, however, is fetch the value direct from ACF using get_field in the “Organization” column: first check whether $value is empty, use get_field (or get_post_meta) to fetch the value from “Organization (Common)” and set $value to that.

    Does this answer your question?

    Thread Starter dawiyo

    (@dawiyo)

    Thanks Jesper! I can’t believe I didn’t think of that! It’s working just fine now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get value of another column (to combine 2 columns)’ is closed to new replies.