Skip Navigation

[Resolved] Connect message system with user profil

This support ticket is created 4 years, 10 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Lara 4 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1410993

I am trying to: I try to connect every newly created message in the Toolset message system with the post type "user profil" of the currently logged-in user. It works fine, with the first message in a conversation. However if I try to implement it in the "reply form" it get's messy. I can either get the connection "message -- user profil of the currently logged-in user" or "Re: Post titel of First message" as a post titel, but not both at the same time. If I use the connection "message -- user profil of the currently logged-in user", the post titel of the reply will be "Re: Name User Profil of the currently logged-in user"

Code:

New message form on the "user profil" page (post type)

[credform class='cred-form cred-keep-original']
[cred_field field='form_messages' value='' class='alert alert-warning']
<div class="form-group">
  <label>[wpml-string context='cred-form-New message-4715' name='Message Name']Betreff der Nachricht[/wpml-string]</label>
	[cred_field field='post_title' post='message' value='' urlparam='' class='form-control' output='bootstrap']
</div>
<div class="form-group">
	<label>[wpml-string context='cred-form-New message-4715' name='Message description']Schreibe deine Nachricht[/wpml-string]</label>
  [cred_generic_field field='post_content' post='message'  type='textarea' value='' urlparam='' output='bootstrap']
{
"required":1,
"validate_format":1,
"persist":0,
"default":""
}
[/cred_generic_field]
</div>

[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":"[wpv-post-author format='meta' meta='id']"
}
[/cred_generic_field]

<div class="hide">
[cred_field field='@verbindet-absender-einer-nachricht-mit-der-nachricht.parent' class='form-control' output='bootstrap' value='[wpv-post-id]']
</div>

[cred_field field='form_submit' value='Senden' urlparam='' class='btn btn-primary btn-lg' output='bootstrap']

[/credform]

Reply message form in a "container", that load the "pofil page" (post type) of the currently logged-in user

[credform class='form-dark']
<div class="hidden">[cred_field field='post_title' post='message' value='Re: [wpv-post-title item="current_page"]' urlparam='' class='form-control' output='bootstrap']</div>

[wpv-conditional if="( $(wpcf-message-from) ne '[wpv-current-user info="id"]' )"]
  [cred_generic_field field='wpcf-message-to' type='hidden' class='' urlparam='']
  {
  "required":0,
  "validate_format":0,
  "persist":1,
  "generic_type":"user_id",
  "default":"[types field='message-from' output='raw'][/types]"
  }
  [/cred_generic_field]
[/wpv-conditional]

[wpv-conditional if="( $(wpcf-message-from) eq '[wpv-current-user info="id"]' )"]
  [cred_generic_field field='wpcf-message-to' type='hidden' class='' urlparam='']
  {
  "required":0,
  "validate_format":0,
  "persist":1,
  "generic_type":"user_id",
  "default":"[types field='message-to' output='raw'][/types]"
  }
  [/cred_generic_field]
[/wpv-conditional]


[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-first-message-id' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[types field='first-message-id']"
}
[/cred_generic_field]

<div class="hide1">
[cred_field field='@verbindet-absender-einer-nachricht-mit-der-nachricht.parent' class='form-control' output='bootstrap' value='[wpv-post-title]']
</div>


<div>   
[cred_generic_field field='post_content' type='textarea' placeholder='Schreibe eine Antwort ...' urlparam='']
{
"required":1,
"validate_format":0,
"default":""
}
[/cred_generic_field]
</div>

<div>
[cred_field field='form_submit' value='Senden' urlparam='' class='button-secondary']
</div>

[/credform]

I expected to see:
1) The connection "message -- user profil of the currently logged-in user".
2) The post titel of the reply "Re: Post titel of First message"

Instead, I got:
1) The connection "message -- user profil of the currently logged-in user".
2) The post titel of the reply "Re: Name User Profil of the currently logged-in user"

#1412249

Hello, the correct syntax to get the title of the current page uses the $ symbol:

[cred_field field='post_title' post='message' value='Re: [wpv-post-title item="$current_page"]' urlparam='' class='form-control' output='bootstrap']

However, I don't think this will work for you because the current page is a User Profil post, not the original Message post. You need a way to get the ID of the original Message post here, so you can access its post title. If the wpcf-first-message-id field is set correctly, you might be able to use that to get the title of the original message like this:

[cred_field field='post_title' post='message' value='Re: [wpv-post-title item="[types field='first-message-id' output='raw'][/types]"]' urlparam='' class='form-control' output='bootstrap']

However, this is pushing the limits of the maximum level of nested shortcodes and may or may not work. I would need to see how it's implemented.

As far as the post relationship, I think this field should be updated to use the current post ID, not the current post title:

[cred_field field='@verbindet-absender-einer-nachricht-mit-der-nachricht.parent' class='form-control' output='bootstrap' value='[wpv-post-id item="$current_page"]']

Please try those updates and let me know the results, and we can go from there.

#1412613

Hello Christian,

many thanks for your answer.

[cred_field field='post_title' post='message' value='Re: [wpv-post-title item="[types field='first-message-id' output='raw'][/types]"]' urlparam='' class='form-control' output='bootstrap']

You are right, this is pushing the limits of the maximum level of nested shortcodes and it doesn't work.

I would like to give you a little bit more background information regarding the implementation:

It is a nested view:
The first view is a duplicat of the [wpv-view name="Related messages"] view. However it only loads 1 item. It's name is [wpv-view name="Related messages - First message"]. Inside this view there is the container, that load the user profil of the currently logged in user ( [wpv-view name="reply-message-container"] ). Inside the [wpv-view name="reply-message-container"] container there is the reply form. If you can imagine another way to connect the "user profil page" with the "message", we can delete the container.

Here is the code of the [wpv-view name="Related messages - First message"] view:

[wpv-layout-start] [wpv-items-found] 
<!-- wpv-loop-start -->  
<wpv-loop>      

  
  <div class="message-item" id="[wpv-post-slug]">
    
    <div class="first-message">
      [wpv-post-body view_template="None"]
    </div>
    
    
    
     <div data-toggle="collapse" data-target="#verlauf-[wpv-post-id]" role="button" aria-expanded="false" aria-controls="verlauf-[wpv-post-id]">
      <p>Nachrichtenverlauf lesen <i class="fa fa-envelope" aria-hidden="true" title="reply"></i></p>     
    </div>
    
    <div class="verlauf collapse" id="verlauf-[wpv-post-id]">
      [wpv-view name="TEST Related messages" message="[types field='first-message-id' raw='true'][/types]"]  
    </div>
    
    
    <div data-toggle="collapse" data-target="#antworten-[wpv-post-id]" role="button" aria-expanded="false" aria-controls="antworten-[wpv-post-id]">
      <p>antworten <i class="fa fa-reply" aria-hidden="true" title="reply"></i></p>     
    </div>
    
    <div class="antworten collapse" id="antworten-[wpv-post-id]">
      [wpv-view name="reply-message-container"]
    </div>


    </div>
    
 
</wpv-loop>
<!-- wpv-loop-end -->
[wpv-pager-nav-links output="bootstrap"] [/wpv-items-found] 
[wpv-no-items-found]
[wpml-string context="wpv-views"][/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

Kind regards
Lara

#1412617

There is an additional problem. If I use the [wpv-view name="reply-message-container"] container, instead of the reply form, then the message doesn't show up in the inbox of the receiver.

#1413863

My issue is resolved now. Thank you! I found a solution by accident.

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