• Resolved Eric McNiece

    (@emcniece)


    For some strange reason, I can’t seem to get the cpac_get_column_value_custom_field hook to work. Here’s the code I’m using, straight from an example:

    add_filter( 'cpac_get_column_value_custom_field', 'format_cpac_fields', 10, 5 );
    function format_cpac_fields( $value, $internal_field_key, $custom_field, $type, $object_id )
    {
    
        $my_post_type  = 'demo';
        $my_field_name = 'city';
    
        // make sure we have the correct posttype and fieldname
        echo $custom_field;
        if ( $my_field_name == $custom_field ) {
    
            if ( '33' == $value )
                $value = 'Amsterdam';
    
            elseif ( '34' == $value )
                $value = 'New York';
        }
        return 'test';
    }

    Even though the if statement won’t execute since I don’t have a field named ‘city’, I’ve hard-coded a return value to substitute any fields that might be passing by. I’ve also echoed out $custom_field. Alas, nothing changes in my post columns!

    Any hints for where I can start troubleshooting?

    http://wordpress.org/plugins/codepress-admin-columns/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tobias Schutter

    (@tschutter)

    I have changed some of the filter/hooks. Currently working on the docs for them. I will return with a working example when I can !

    Any word on this?

    I had to revert to version 1.4.9 to use the customization code above.

    Hopefully, the old filter will work again since it was and still is featured in the documentation. Either way, thank you so much for the quality plugin!

    I suppose I’ll have to revert to an old version as well. I appreciate the version number dotkev.

    Hey, I read through the sourcecode and was able to figure this out for 2.x. Too bad the developer is too tired to update the docs, as the code is already in place. Here what works for me on CAC 2.x:

    function cpac_birthday_to_age( $value, $id, $cac )
    {
    	$post_type = 'people';
    	$custom_field = 'birthday';
    
    	if ( ($cac->storage_model->key == $post_type) && ($cac->options->field == $custom_field) )
    	{
    		$age = substr($value,6,4);
    		$today = date('Y');
    		$age = $today-$age;
    		$age = "(".$age.")";
    		$bday = date('F j, Y', strtotime($value));
    		$value = $bday." ".$age;
    	}
    
        return $value;
    
    }
    add_filter( 'cac/column/meta/value', 'cpac_birthday_to_age', 10, 5 );
    Plugin Author Tobias Schutter

    (@tschutter)

    Above example will work. I have also updated the FAQ with a working example.

    http://wordpress.org/plugins/codepress-admin-columns/faq/

    @ethanpil It’s not because we are tired, but very busy maintaining this plugin 😉 And thanks for the example.

    Thanks for the code ethanpil!

    Also, again, thanks for the awesome work on the plugin. We know you’re not slacking in the least!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘cpac_get_column_value_custom_field won't fire’ is closed to new replies.