Skip Navigation

[Resolved] Message Module – To Recipient ID always zero

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

Last updated by Christian Cox 5 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1143991

Tell us what you are trying to do?

Test message module prior to implementation

Is there any documentation that you are following?

https://toolset.com/learn/how-to-create-a-messaging-system-with-toolset/

Is there a similar example that we can see?

Yes if needed

What is the link to your site?

Ihave followed the instructions to implement the new message module and all looks to be workinng except the "To" usre ID is not being populated - it's zero.

I have made sure the author is correct on the contractor page and can display the user ID fine.

Ithink I have got something wrong somewhere - maybe you could suggest what I might be missing and I will have another look.

Thanks
Tony

#1144430

Not being a programmer, my code knowledge is limited but I don't see the functions.php code that stores "wpcf-message-to".

Is there some cred hook code missing in your instructions?

Thanks
Tony

#1144491

Hi, the wpcf-message-to slug refers to a Types custom field. Since the generic field is configured to use the same slug, the value is stored automatically without the need for any custom code. If the "to" address is stored as 0 in wp-admin, it could be because of where the New Message Form is displayed. The Form should be placed in the Author archive in order to work as written. It's already placed there when you import the Module. Go to Toolset > WordPress Archives > Author archive.

Then you can visit the New Message form by going to yoursite.com/author/username (replace username with the desired recipient's username). Then the custom shortcode get_author_id_in_archive will supply the correct User ID in your recipient generic field. If you place the New Message Form somewhere else, then you must edit the New Message Form, remove the get_author_id_in_archive shortcode, and pass in the User ID of the intended recipient some other way. Otherwise, the intended recipient's ID will not be correct.

#1144499

Ah! Thanks Christian.

I was using the module in a club membership system so that club members could communicate with each other. To do that I needed some additional fields (set by a member) to say whether or not they were a part of the message facility. That is, they can opt out if they want.

I therefore created a post type and set the author = member, added the additional fields and then added the message send form. A member can display the post type of another club member and if they accept messages, the form would appear.

I will have to have another look at this and see how I can adapt what I have done.

At least I now know why it did not work for me and will be able to find a suitable solution.

Thanks again.
Tony

#1144528

Sure, no problem. Let me know if you get stuck.

#1144880

Hi Christian

I thought I could implement a simple change to the CRED form by changing

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

TO ----------------------

[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]

-----------------------------

expecting [wpv-post-author format='meta' meta='ID'] to be the user id of the post on which the CRED form is placed. Unfortunately it delivers the logged in user id.

Is there a parameter that can be added to [wpv-post-author format='meta' meta='ID'] so that the parent post can be used to supply the user id?

I am trying to avoid changing too much code.

Kind regards
Tony

PS I appreciate that this may be a legitimate support question but it might be useful to other Toolset Users.

#1145215

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tony,

Christian is on Holiday today and will be back tomorrow to answer any concerns you may have.

Thanks,
Shane

#1145964

You can use the "id" attribute of the wpv-post-author field to specify which post you want to query. If you want to access the author of the current post, you can use the $current_page operator like this:

[wpv-post-author format='meta' meta='ID' id='$current_page']
#1146369

Thank you Christian - that does the job fine the from/to codes are now correct and I am able to adapt the message system to a membership site with just that one line change.

======
Hi [/types]“],

You have a message from [/types]“] [/types]“].
=======

The code in the email message is:

===========
<p>Hi [wpv-user field="user_firstname" id="[types field='message-to' output='raw'][/types]"],</p>
<p>You have a message from [wpv-user field="user_firstname" id="[types field='message-from' output='raw'][/types]"] [wpv-user field="user_lastname" id="[types field='message-from' output='raw'][/types]"].</p>
<p>Message: [wpv-post-excerpt length="80" more="..."]</p>
<p>This is an automated email, please do not reply to it.</p>
<p>You can reply <a href="[wpv-post-url]">directly here</a>.</p>
============

I don't recall changing this yet so I wondered if there may be a problem with the syntax.

I recall that sometimes " and ' characters can cause problems.

Many thanks
Tony

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/message-module-types-field-shortcodes-appear-in-email-notifications/

#1146560

Okay great, I have split your question about the email notifications into a separate ticket, since it seems to be a bit different from the question about recipients and we have a one topic per ticket policy. I'll follow up there shortly: https://toolset.com/forums/topic/message-module-types-field-shortcodes-appear-in-email-notifications/

#1148642

My issue is resolved now. Thank you!

#1148643

For information only.

Whenever I have something that I need to resolve, I (like others) always look for the solution within the help pages and previous support messages. Some things are very difficult to find for unskilled users.

For example, this solution (for me) was

[wpv-post-author format='meta' meta='ID' id='$current_page']

I knew about [wpv-post-author] but was/am not familar with the parameters that can be added. Adding a selection of useful adaptations of a short code (for dummies) would be simple to do and would save some support questions.

Dummies like copy and pasting code and makin changes to the bits they understand!

Experts can look at code and know what it all means so please take a look at the short codes and provide some useful examples without over describing things.

Thanks for the great support.

Tony

#1149245

Thanks for the suggestion, I can see how this would be helpful. The best way to get new features added to the site or the software is to create a new ticket here in the forum using the "Suggest an improvement" option. This will put your request in front of our developers and documentation team, and they can decide how to best implement this new feature.

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