Skip Navigation

[Resolved] I need to know the exact parameters to set up the messaging system using blocks

This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 17 replies, has 2 voices.

Last updated by Minesh 3 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#1737477
related message set up.png
outbox set up.png
Inbox set up.png
Message back end.png

I am trying to set up the messaging system.
I have set up:
Inbox
Outbox
Related messages
but it is not returning the correct data

In the back end it is not recording the Message To or First Message ID (see attached - Message back end.png) the form that is submitted is on a custom post type template which is created by a unique user. I expected the Message to field to be populated by the author of the page but nothing appears in the back end.

When i create the Inbox page i want to check i have the correct query filter. Can you confirm that {!{wpv-current-user info='id'}!} is the correct parameter (see attached - Inbox set up.png)

Can you also confirm that i have the correct set up of the outbox. (see attached - outbox set up.png)

The final issue is that the related message set up is not working. Can i check the parameters that i have used is correct. It does not appear to be retrieving the first message correctly. (see attached - related message set up.png)

Thanks in advance

#1738275

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Do you know that Toolset offers the messaging system module:
=> https://toolset.com/modules/messaging-system/

Are you using the same module? if Yes:
- I will require access details and problem URL where you added the message form and what content is not get stored when you submit the message.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1739005

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share problem URL where I can see the message for you added and can you please tell me what exactly not working.

#1739013
Message back end.png

I have set up the following pages (you will need to be logged into see the menu items):
Inbox - hidden link - i think this working correctly, it should only show messages for the logged in user. Please can you double check it is set up correctly though as the query string may be wrong?
Outbox - hidden link - again i think this is only showing the user messages out which is correct

So i am logged in as user 6 and the outbox shows the correct message i have sent hidden link. When i click through to see the message thread it pulls up a different message

I am not convinced i have all of the query parameters correct and i do not understand why the messages list in the back end is not showing the correct data

#1739025

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share the user login details other than admin for which I should test the messages.

I will require two users for which I should test the message system. One user should be as sender and one user should be as receiver.

I have set the next reply to private which means only you and I have access to it.

#1742079

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check User 1: and User 2: inbox and outbox.

With the following form - I've changed the field "wpcf-message-to" default attribute to:[wpv-post-author format='meta' meta='ID']

[cred_generic_field field='wpcf-message-to' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"generic_type":"user_id",
"default":"[wpv-post-author format='meta' meta='ID']"
}
[/cred_generic_field]

Can you please confirm it works as expected now.

#1742087
Thread view 1.png
User 1_Inbox.png

It appears that the inbox and the outbox pages are showing the right messages.
However, if you are in the inbox and you click the message the detail page is not presenting the threaded message correctly.
Example:
I am logged in as User 1 - go to Inbox - You see Toolset-test-msg-2 (see attached User 1 Inbox.png)

If you click on the message to view the full message it loads this page hidden link

It is not retrieving the original message (see attached View Thread 1.png) it is showing a completely different message

#1742727

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please make sure you followed the following doc and all fields mentioned are added to form and post.
=> https://toolset.com/documentation/legacy-features/views-plugin/how-to-create-a-messaging-system-with-toolset/

#1743347
related message set up toolset.png
Blocks editing view.png

I have followed that guidance but it is not clear what value i need to put in the Message front end template to retrieve the current message in the view.

When editing the page template: Message – single item

There is a query string (see right hand side of page - Blocks editing view.png) leaving this field blank does not show the current message thread.

Looking at the toolset guidelines you sent me (see attached - related message set up toolset.png) does not show the same query field. I cannot work out how to translate the code on this page https://toolset.com/documentation/legacy-features/views-plugin/how-to-create-a-messaging-system-with-toolset/ to the blocks view query string.

#1743873

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - the query string name there needs to be passed as message.

In addition to that, first of all, Can you please update ALL Toolset plugins on your staging site to the current version. We always recommend running your site with the latest stable release plugin version.

*** Please make a FULL BACKUP of your database and website.***
Could you please update ALL Toolset plugins to it's latest officially released version. You can download the latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/

Once you update the plugins and set the query string as message. Please let me know if you will require further assistance.

#1745169
reply message test.png

I have updated all of the toolset plugins and added message as the query string. I still have the same issue.

When i login as User 1, go to inbox, click on the message to be able to reply it does not show the correct original message on the screen. I can however reply.

I think the issue is that it is not recording the first message ID in the back end (see attached screen shot) that field is blank. I replied to a message (second item in the attached image) and i would expect it to show the first message id which was related to the Toolset-test-message-2 original message

#1745219

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now.

i've added the following code to "Custom Code" section offered by Toolset:
=> hidden link

add_action( 'cred_save_data_7754', 'set_post_id_in_field', 10, 2 );
function set_post_id_in_field( $post_id, $form_data ) {
    update_post_meta( $post_id, 'wpcf-first-message-id', $post_id );
 
 
    $content = get_post_field('post_content', $post_id);
    $content = str_replace('[','{{',$content);
    $content = str_replace(']','}}',$content);
    $my_post = array(
        'ID'           => $post_id,
        'post_content' => $content,
    );
// Update the post into the database
    wp_update_post( $my_post );
}

add_action( 'cred_save_data_7755', 'remove_shortcodes_from_message', 10, 2 );
function remove_shortcodes_from_message( $post_id, $form_data ) {
 
    $content = get_post_field('post_content', $post_id);
    $content = str_replace('[','{{',$content);
    $content = str_replace(']','}}',$content);
    $my_post = array(
        'ID'           => $post_id,
        'post_content' => $content,
    );
// Update the post into the database
    wp_update_post( $my_post );
}

add_filter( 'wpv_filter_query_post_process', 'contractors_messages_list_filter', 10, 3 );
function contractors_messages_list_filter( $query, $view_settings, $view_id ) {
    if ( $view_id == '7760' || $view_id == '7758' ) {
        $threadIDs = [];
        $queryFiltered = [];
 
        foreach ( $query->posts as $post ) {
            $threadID = get_post_meta( $post->ID, 'wpcf-first-message-id', true );
 
 
            if ( !in_array( $threadID, $threadIDs ) ) {
                $threadIDs[] = $threadID;
                $queryFiltered[] = $post;
            }
        }
        $query->posts = $queryFiltered;
        $query->found_posts = count( $queryFiltered );
        $query->post_count = count( $queryFiltered );
    }
    return $query;
}

function get_author_id_in_archive_func($atts) {
$author_id = 0;
if (is_author()){
$author = get_queried_object();
$author_id = $author->ID;
}
return $author_id;
}
add_shortcode("get_author_id_in_archive", "get_author_id_in_archive_func");

I thoughts you already followed the guide and added it but you did not so i've added the above code and can you please check now if its working as expected now.

With the following page - i've added the view using shorcode block:
=> hidden link

[wpv-view name="my-messages-received" info="[wpv-current-user info='id']"]

I've also made little adjustment with your "Reply message" form:
=> hidden link

Can you please check User 1 and User 2 and confirm it works as expected now.

#1746309
With message query filter.png
Without message query filter.png

So we are now recording the first message id thank you.

On the toolset - Message - single item template it should display the first message and then the reply form. The query filter you suggested i use is 'message' but this returns no content. If you remove the query filter it displays all messages.

The query filter must be something different.

See attached
With messages image (attached)
Without messages image (attached)

#1746361

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now: hidden link

I've added the view using the shortcode block on your single message page as given under:
=> hidden link

[wpv-view name="contractor-related-messages" message="[types field='first-message-id' output='raw'][/types]"]

Can you please confirm it works as expected now.

#1746463

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please confirm everything works as expected now.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.