WordPress.org

Ready to get started?Download WordPress

Forums

Codepress Admin Columns
[resolved] Request: add format filter to CPAC_Values::get_column_value_custom (3 posts)

  1. lukewarmmizer
    Member
    Posted 1 year ago #

    Hi,

    I noticed that you have included a filter in Codepress_Admin_Columns->get_box_options_customfields()

    $fieldtypes = apply_filters('cpac-field-types', $fieldtypes );

    However there isn't a way that I can see to add a new format to this new field type. In CPAC_Values::get_column_value_custom_field() I added the following code on line 299

    $meta = apply_filters('get_column_value_custom_field', $meta, $fieldtype );

    In my case it lets me show a username when a user id is being save, like so:

    function admin_column_user_filter($fieldtypes){
    	$fieldtypes['user_by_id'] = 'User (by UserId)';
    	return $fieldtypes;
    }
    add_filter('cpac-field-types', 'admin_column_user_filter');
    function get_column_value_custom_field($meta, $type) {
    	if ($type=="user_by_id"){
    		$userdata= get_userdata($meta);
    		if ( $userdata )
    			$meta = $userdata->user_login;
    	}
    	return $meta;
    }
    add_filter( 'get_column_value_custom_field','get_column_value_custom_field', 10, 2 );

    It would be great to have this filter added if possible so that it isn't just a hack on my side, thanks!

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

  2. Bart Dabek
    Member
    Posted 1 year ago #

    Any word on implementing filter per field type?

  3. Codepress
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    Nice to see you are making use of the added filters :)

    You example is very clear and it makes a good point. I will be adding your suggested filter (with a prefix) to the next release (1.4.5 and up).

    Cheers,

    Tobias

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.