Skip Navigation

[Resolved] Show conditional content (only original author) on a view

This support ticket is created 3 years 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 32 replies, has 3 voices.

Last updated by Minesh 2 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2044799

Yes, message forms are set up correctly but users cant view it on page view.

#2046233

Minesh
Supporter

Languages: English (English )

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

here is the first update:

The content template that displays the "Contactar" button:
You configured the link as given under:
=> hidden link;

I changed the link as given under:
=> hidden link;

Instead of using "contact_id" in URL we will use "parent_empresa_id" so that the parent empresa ID will be automatically selected on the form:
=> hidden link;

I will still check further (tomorrow) and let you know.

#2047499

Minesh
Supporter

Languages: English (English )

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

This is the post created by User A:
=> hidden link

Now, visiting the above post as User B and when we click on the "Contactar" button the user is redirected on the following page:
=> hidden link
[Please remember that we changed the "contact_id" URL param to "parent_empresa_id", I shared those details with my previous reply]

I see you are using the following form on the above page:
=> hidden link

Within the form I see the field added as:

<div class="form-group" style="display:none;">
		<label>[cred_i18n name='email-destinatario-label']Email destinatario[/cred_i18n]</label>
		[cred_field field='email-destinatario' force_type='field' class='form-control' output='bootstrap' value='[cust_get_author_meta]']
	</div>

But when I see the source code, I do not see any email assigned to value attribute. Can you please tell me what email you want to assign to "email-destinatario" field:
- Is it currently Loggedin user (User B)
- or its should be the parent post author user email (User A)

Can you please confirm?

#2050235

Hello Minesh,

'' This is the post created by User A:
=> hidden link

Now, visiting the above post as User B and when we click on the "Contactar" button the user is redirected on the following page:
=> hidden link
[Please remember that we changed the "contact_id" URL param to "parent_empresa_id", I shared those details with my previous reply]

I see you are using the following form on the above page:
=> hidden link ''

That's okay.

Email that has to be assigned to 'email-destinatario' field is userA (post author user mail), because i need that user a can receive via email the notification when user B send the form.

Thanks
After that, user A will be able to see the message in his view of the personal area (hidden link)

I hope it helps you

#2053349

Minesh
Supporter

Languages: English (English )

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

I see even I asked you to follow the message system:
=> https://toolset.com/documentation/legacy-features/miscellaneous/how-to-create-a-messaging-system-with-toolset/

I see you did not make any changes as per the message system and that is why its not working.

To the following from - i've added the following generic fields:
=> hidden link

[cred_generic_field field='wpcf-message-from' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"generic_type":"user_id",
"default":"[wpv-current-user info='id']"
}
[/cred_generic_field]	
[cred_generic_field field='wpcf-message-to' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"generic_type":"user_id",
"default":"[cust_get_author_meta type='id']"
}
[/cred_generic_field]

I've also adjusted the code to code snippet "passinfotocontact" added at "Custom Code" section as given under:

function cust_get_author_meta($atts) {
 
    
 	if(isset($_GET['parent_empresa_id'])){
     $post_id = $_GET['parent_empresa_id'];
     $post = get_post($post_id);
      
     $all_data = get_userdata($post->post_author);
    if(isset($atts['type']) and $atts['type']=='id'){
      
     return $all_data->data->ID;
    }else{  
     return $all_data->data->user_email;
    }
    }
 }
add_shortcode( 'cust_get_author_meta', 'cust_get_author_meta' );

add_action( 'cred_save_data_2382', 'func_set_first_message_id_field', 10, 2 );
function func_set_first_message_id_field( $post_id, $form_data ) {
    update_post_meta( $post_id, 'wpcf-first-message-id', $post_id );
}

As you can see I've adjusted the code for custom shortcode "cust_get_author_meta" and also added hook "cred_save_data_2382".

This is the view used to display the Received Message:
=> hidden link

Then, to the personal details page:
=> hidden link
i've added the view as given under:

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

When I visit the page personal area page on frontend logged in as User A, under the section "Direct messages received" I can see the message.
=> hidden link

Please make sure once you send the message, you must approve it.

Please kindly follow the Doc I shared and make sure your Reply Message form should hold the correct fields as stated with the following Doc:
=> https://toolset.com/documentation/legacy-features/miscellaneous/how-to-create-a-messaging-system-with-toolset/#reply-message-form

#2055079

Hello Minesh,

Thank you for your help

I will try to improve your last indications.

I will try and if I am not able, I will let you know in this topic

Thank you

#2055085

Minesh
Supporter

Languages: English (English )

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

Ok great - Glad to help. If you see it working please feel free to mark resolve this ticket.

#2057763
Captura de pantalla 2021-05-17 a las 12.30.42.png
Captura de pantalla 2021-05-17 a las 12.30.38.png
Captura de pantalla 2021-05-17 a las 12.25.42.png
Captura de pantalla 2021-05-17 a las 12.24.17.png

HI Minesh,

I think that something is not working well.
I tried to see received messages on personal area of users and i can see all messages.
I guess that filters or something like that are not working as we expected.

i.e: user joseangel created a 'Mensaje Directo' sended to user alejandro.
But when i log in as alejandro, i can see all messages created on my personal area page even those messages created by admin.
And something messages which have Administrator author, it displays as: current author name. (you can see on image attached as: Manuel Alejandro (user alejandro))

#2058057

Minesh
Supporter

Languages: English (English )

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

On the following page: hidden link

I see you were not using the correct view - as you can see with the following edit page, I've adjusted the correct view and added the following view using "Fields and Text" block:
=> hidden link

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

I can see its showing the correct results.

#2059401

Okay, you are right.

Thank you Minesh.

I m trying that i told you days ago.
As soon as i can, i'll send you a message.

#2059721

Hello Minesh,

I think that i set up correctly all steeps you gave me on documentation: https://toolset.com/documentation/legacy-features/miscellaneous/how-to-create-a-messaging-system-with-toolset/#reply-message-form

. . .but i have a doubt: I created forms and reeply forms and they are working good. Forms publish new pages with messages inside.

Do you know if there is any way to show original message and his reply below and so on?

Thank you.

#2060789

Minesh
Supporter

Languages: English (English )

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

Have you added the filter "wpv_filter_query_post_process" as given in the document?
=> https://toolset.com/documentation/legacy-features/miscellaneous/how-to-create-a-messaging-system-with-toolset/#form-hooks-query-post-process-filter

See the information:

The inbox and outbox should display only the latest message in the thread. In order to achieve this, a wpv_filter_query_post_process filter is used along with a function which picks the latest post for each message thread.

#2060947
chat-support-toolset.png

Hello Minesh,

Okay, yes. I added snippet.

You are right but show messages like chat is possible? thats i meant

ie: first message on the top of page and reply below, when user created a reply, he can see original message and the reply.

i attach an image that i'm trying to do.

Thank you

#2060989

Minesh
Supporter

Languages: English (English )

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

I'm not sure from where you grab the above image but we have limited options and limited features with basic messaging system.

As you can see it working - you can design it as per your requirement and feel free to extend it as per your requirement.

Even if you will require custom programming you are welcome to contact our certified partners:
=> https://toolset.com/contractors/

#2061047

Okay Minesh,

Thank you

Do you think that it could be possible to show the message and his parent on a view?

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