• Resolved bastibln

    (@bastibln)


    Hello,

    for my personal requirements I need to adapt one file in this plugin. Thus, I want to copy this php-file to my child theme to make it safe against updates. Is there any trick why my previous solution is not working for this plugin?

    I safed the php-file “class-field-type-from-to.php” under the following path:

    /wp-content/themes/my-child-theme/src/field-types

    Does anyone has a hint here? Thanks a lot.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author raviousprime

    (@raviousprime)

    Hello,
    You can not override plugin files through a child theme. Please let me know what you are trying to achieve so I can help.

    Thread Starter bastibln

    (@bastibln)

    Hey,

    hm okay. Actually it’s just a cosmetical edit, I want the separators to have some space between the numbers. So if a user enters a From-To Value [10,20] I want it to be displayed in the frontend like “10 – 20” instead of “10-20”. Thus, I just want to add two spaces around the “-” separator. I assume this is not possible via CSS. At least I tried and didn’t manage successfully.

    Thanks for your support.

    • This reply was modified 9 months, 2 weeks ago by bastibln.
    • This reply was modified 9 months, 2 weeks ago by bastibln.
    Plugin Author raviousprime

    (@raviousprime)

    Hello,
    Use this code in your ‘bp-custom.php’ file.
    Please try the following code:

    add_filter( 'bp_get_the_profile_field_value', function ( $value, $field_type, $field_id ) {
    
    	if ( 'fromto' === $field_type ) {
    		$user_id = bp_is_user() ? bp_displayed_user_id() : bp_get_member_user_id();
    
    		if ( ! $user_id ) {
    			return $value;
    		}
    
    		$separator = bp_xprofile_get_meta( $field_id, 'field', 'separator_token', true );
    		$separator = empty( $separator ) ? ' - ' : " $separator ";
    
    		$field_value = explode( ',', xprofile_get_field_data( $field_id, $user_id, 'comma' ) );
    		$field_value = array_map( 'trim', $field_value );
    
    		if ( count( $field_value ) !== 2 ) {
    			return $value;
    		}
    
    		$value = sprintf( '<span class="bpxcftr-fromto-from-value">%1$s</span>%3$s<span class="bpxcftr-fromto-to-value">%2$s</span>', $field_value[0], $field_value[1], $separator );
    	}
    
    	return $value;
    }, 10, 3 );
    Thread Starter bastibln

    (@bastibln)

    Wow, thanks a lot for the quick and great help. This works perfectly.

    Have a wonderful day !

    Plugin Author raviousprime

    (@raviousprime)

    Thank you for the acknowledgement. I am glad that I could help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Child Plugin’ is closed to new replies.