BuddyDev

Search

How to make changes at the values from the invitations loop before output

  • Participant
    Level: Enlightened
    Posts: 44
    Alex on #53299

    Hello Brajesh,
    I am still stuck on the invitations feature in BP :-(((
    Finally I got the limitation for spammers work! But now I have problems to change the datetime format. The invitations loop prints it out as “2024/10/14 8:24:28 am”.
    I would like to have it as “14.10.2024” without the time and also manipulate the ‘message’ to print out as an excerpt instead of the whole text before output.

    My try was to change on of these functions at the bp-members-template.php:

    function bp_the_members_invitation_property( $property = ”, $context = ‘html’ ) {
    if ( ! $property ) {
    return;
    }

    // phpcs:ignore WordPress.Security.EscapeOutput
    echo apply_filters(
    /**
    * Use this filter to sanitize the output.
    *
    * @since 8.0.0
    *
    * @param int|string $value The value for the requested property.
    * @param string $property The name of the requested property.
    * @param string $context The context of display.
    */
    ‘bp_the_members_invitation_property’,
    bp_get_the_members_invitation_property( $property ),
    $property,
    $context
    );
    }
    /**
    * Return the value for a property of the network invitation currently being iterated on.
    *
    * @since 8.0.0
    *
    * @return int ID of the current network invitation.
    */
    function bp_get_the_members_invitation_property( $property = ‘id’ ) {

    switch ( $property ) {
    case ‘id’:
    case ‘user_id’:
    case ‘item_id’:
    case ‘secondary_item_id’:
    case ‘invite_sent’:
    case ‘accepted’:
    $value = 0;
    break;
    case ‘invitee_email’:
    case ‘type’:
    case ‘content’:
    case ‘date_modified’:
    $value = ”;
    break;
    default:
    // A known property has not been specified.
    $property = null;
    $value = ”;
    break;
    }

    if ( isset( buddypress()->members->invitations->query_loop->invitation->{$property} ) ) {
    $value = buddypress()->members->invitations->query_loop->invitation->{$property};
    }

    /**
    * Filters the property of the network invitation currently being iterated on.
    *
    * @since 8.0.0
    *
    * @param int|string $value Property value of the network invitation being iterated on.
    */
    return apply_filters( ‘bp_get_the_members_invitation_property_’ . $property, $value );
    }

    I tried to add a this filter, but it doesnt work. Are you able to help me out? Whats wrong with the filter or do I hook into the wrong function??

    add_filter(‘bp_get_the_members_invitation_property_’,function ($property,$value) {
    if ($property == ‘date_modified’){
    $value= date(‘d.m.Y’,strtotime($value);
    }
    return $value;
    },10,2);

  • Participant
    Level: Enlightened
    Posts: 44
    Alex on #53300

    By the way. I tried to edit my post because I forgot the code blocks but it says you cannot create new topics??

    
    
    add_filter(‘bp_get_the_members_invitation_property_’,function ($property,$value) {
    if ($property == ‘date_modified’){
    $value= date(‘d.m.Y’,strtotime($value));
    }
    return $value;
    },10,2);
    
    
  • Keymaster
    (BuddyDev Team)
    Posts: 24524
    Brajesh Singh on #53313

    Hi,
    You may want to try something like this

    
    
    add_filter( 'bp_get_the_members_invitation_property_date_modified', function ( $value ) {
    	return date( 'F.j.Y', strtotime( $value ) );
    } );
    
    

    Let me know if that works or not? I might need some adjustment.

You must be logged in to reply to this topic.

This topic is: not resolved