Insert "Note" field in the service provider profile, mu-plugin ?

Hi !
I would like for my service providers to see the field "Notes" when they log on to their profile. Is there a way to do that ?

Thanks !
F.

  • Nithin
    • Support Wizard

    Hi Françoise,

    Hope you are doing good today. :slight_smile:

    You want new a custom field in service providers profile page? Or are you talking about a "Notes" field which is already present is the Appointments+ settings?

    This would require custom coding, however could you please explain further if I'm missing out anything, so that I could check this with the developer, and see whether there is a quick workaround.

    Kind Regards,
    Nithin

  • Panos
    • SLS

    Hi Françoise ,

    Could you try adding the following snippet in a mu-plugin:

    add_filter( 'app_my_appointments_column_name', function( $table_head ){
    
    	return $table_head . '<th class="my-appointments-notes">Notes</th>';
    
    }, 10, 1 );
    
    add_filter( 'app_my_appointments_add_cell', function( $col, $r ){
    
    	$app = appointments_get_appointment( $r->ID );
    	return '<td>' . $app->note . '</td>';
    
    }, 10, 2 );

    This should add a new column "Notes" which should contain the note.

    Please let us know how this works for you :slight_smile:

    Cheers!

  • Panos
    • SLS

    Hey Françoise ,

    Can you try replacing
    app_my_appointments_add_cell
    with
    app-shortcode-my_appointments-after_status

    The whole snippet should look like:

    add_filter( 'app_my_appointments_column_name', function( $table_head ){
    
    	return $table_head . '<th class="my-appointments-notes">Notes</th>';
    
    }, 10, 1 );
    
    add_filter( 'app-shortcode-my_appointments-after_status', function( $col, $r ){
    
    	$app = appointments_get_appointment( $r->ID );
    	return '<td>' . $app->note . '</td>';
    
    }, 10, 2 );

    Thanks!

  • Panos
    • SLS

    Hi Françoise ,

    I'm afraid that in order to add this in a new column you will need to modify core file.

    There is a way to display it in the same column though. If you're interested you can try:

    add_filter( 'app_get_client_name', function( $name, $app_id, $result ){
    
    	$screen = get_current_screen();
    
    	if( ! is_admin() || $screen->id != 'profile' ){
    		return $name;
    	}
    
    	$name = '';
    
    		$result = appointments_get_appointment( $app_id );
    		if ( $result ) {
    			if ( $result->user ) {
    				$userdata = get_userdata( $result->user );
    				if ( $userdata ) {
    					$href = function_exists('bp_core_get_user_domain') && (defined('APP_BP_LINK_TO_PROFILE') && APP_BP_LINK_TO_PROFILE)
    						? bp_core_get_user_domain($result->user)
    						: admin_url("user-edit.php?user_id="). $result->user
    					;
    					$name = '<a href="' . apply_filters('app_get_client_name-href', $href, $app_id, $result) . '" target="_blank">' .
    						($result->name && !(defined('APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES') && APP_USE_LEGACY_ADMIN_USERDATA_OVERRIDES) ? $result->name : $userdata->user_login) .
    					'</a>';
    					$name .= '<br />' . esc_attr(stripslashes($result->address));
    				}
    				else
    					$name = $result->name;
    			}
    			else {
    				$name = $result->name;
    				if ( !$name )
    					$name = $result->email;
    			}
    		}
    
    		return $name;
    
    }, 10, 3 );

    If you prefer to display it in a separate table column, another option would be to add it at the and as we did with the notes.

    Please let me know if you don't agree with the above snipped and if not, what would you prefer, edit core file or add it at the end?

    Thanks!

  • Panos
    • SLS

    Hi Françoise ,

    I just tested again and it seems to be adding the address in my provider's profile page.

    Could you please confirm that the "Address" has been selected to be displayed from admin > Appointments > Settings > Display tab as in the following screenshot:

    Could you also check if the Address field does contain information in the appointments details:

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.