Skip Navigation

[Resolved] Allow guest users to submit Form that posts to landing page owner

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.

Author
Posts
#1392543

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I created a Member for myself and created a Lead Message for my Member so I can test these Views. I added a View "Current User Member ID" that will return the Member ID associated with the current logged-in User if one exists (see current-user-member-id-view.png).

I updated the Elementor design to display the Lead Messages View using a shortcode instead of a View widget. This makes it possible to pass arguments into the View's query filter as I described before. I updated the Lead Message View's query filter to respond to a shortcode attribute "memberid" (see lead-message-query-filter.png).

I have passed the Current User Member ID View results into the Lead Message View shortcode using the "memberid" shortcode attribute I also wrapped the Lead Message View in a conditional so it's only displayed if the current User has a Member post. If not, the View is not displayed (see elementor-page.png).

Here's the conditional and View codes:

[wpv-conditional if="([wpv-view name='current-user-member-id'] ne '')"]
  [wpv-view name="lead-message-view" memberid="[wpv-view name='current-user-member-id']"]
[/wpv-conditional]

Now this page works for me:
hidden link
(see results.png)

Can you test with some other accounts to be sure it's working as expected? If not, I'll need login credentials for that User so I can see what's going on.

#1392597

It seems to be working. Would it be possible to display the list like I did for a "single lead" after clicking your lead on "my-leads" page. You will see now as I created a single template of elementor for each lead-message

I would like all leads in the loop to be numbered and show in a table. Preferably styled like the attached image, but not required, as long as it is functioning properly

if possible, when clicking on the user (going to single lead page) ie lead <someone>
perhaps add a field where lead owner can add notes on that user.

Notes:
Text area field : I spoke with user christian on 11/26, he said call back on the 29th etc...

ie

My-leads page

1) show list as a numbered list (without having to click on each individual lead?)
2) show list as a table (where each lead links to the single lead page)

ex (see attatched image)

Name Phone Email
1. name1 7024651054 email@aol.com
2. name1 5554542124 email2@aol.com

NEXT:

Also I'm going to have one more question (unrelated to this function)

But I want to offer customized download service to users. I already have the download plugins etc to link to amazon. I'm guessing I could use toolset to create a category (My-Video-Downloads) where I as Admin could add File Download links where only the authorized user will see their available download. I'm guessing there is a way to add the "user id" when creating a new field (so that each file uploaded for specific user would show, just like we did with the leads)

then creating a "view" for the my-downloads page that is only for logged in user (any downloads associated w them)

attached is a mock up of the video download page (saying user had 4 available videos to download etc)

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

https://toolset.com/forums/topic/create-a-customized-download-service-for-users/

#1392705

Would it be possible to schedule a time to chat on skype or something so we could just knock out everything at once instead of hours between each comment/question?

#1392801

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I would like all leads in the loop to be numbered and show in a table. Preferably styled like the attached image, but not required, as long as it is functioning properly
Sure, you can format the leads View as a table. Click the "Loop Wizard" button above the Loop Editor in the View editor page and choose the "table" loop style. Then in the next screen you can select which fields you want to display in the table. You can insert the "View Loop Index" field to display the row number. Click Finish when you're all set, and the wizard will generate the loop code automatically. You can edit the generated code manually if you want to add custom CSS or HTML markup to tweak the design.

See the screenshots here for an example of a table View wizard. We also have documentation about the different View loop styles available here: https://toolset.com/documentation/user-guides/view-layouts-101/
And more information about loop shortcodes here: https://toolset.com/documentation/user-guides/digging-into-view-outputs/

If you have questions or need assistance styling a table View, I'll be glad to split that into another ticket so we can discuss in more detail. I'd like to focus on allowing Guests to submit a Form that posts to a Member in this ticket and address other issues independently, as per our support policy: https://toolset.com/toolset-support-policy/

if possible, when clicking on the user (going to single lead page) ie lead <someone>
perhaps add a field where lead owner can add notes on that user.

Since you don't require people to register to create a Lead Message, I would assume you mean you want to add notes on the Lead Message. So you could add a WYSIWYG custom field to the Lead Message post type. Then you can use Toolset Forms to allow the Member to edit the Lead post and update the notes field. We have more information about using Toolset Forms to edit posts and their custom fields here: https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/

NEXT: Also I'm going to have one more question (unrelated to this function)
Okay sure, I will split this into a separate ticket and follow up in turn.

Would it be possible to schedule a time to chat on skype or something so we could just knock out everything at once instead of hours between each comment/question?
We don't offer Skype sessions or video conferences, but we do have a chat feature here in the forum. When you submit a ticket, if a supporter is available to chat you will be able to chat right away about the issue. This feature is best when you have a specific question, as most supporters will enforce chat limits of 30 minutes. If no chat support is available, the ticket will be created as a regular forum ticket and added to the queue to be picked up in turn.

#1393789

I created the lead notes form

It Only allows the user to edit if that user was logged in when form was submitted - which is not relevant as it will be a guest submitting the form. I'm sure there is a setting i'm missing.
I know it is more complicated with the conditionals that most likely need to be in place

Can you just tell me what conditional needs to be inputted to display the edit notes option for the user (no matter if they -irrelevant; or a guest submits form -relevant)

you see 2 lead form submissions on same member page. One was created while user was logged in, one wasn't . Only the one that was created while user was logged in will allow user to edit.

#1393811

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

It Only allows the user to edit if that user was logged in when form was submitted - which is not relevant as it will be a guest submitting the form. I'm sure there is a setting i'm missing.
You're saying the Member is not allowed to edit the Lead Messages submitted by Guests, to add or edit the notes? That's probably because of Access permission settings for this Form. When the Toolset Access plugin is active, you can change Form permissions in wp-admin > Toolset > Access Controls > Toolset Forms. There you can allow specific User roles to use specific Forms to edit others' submissions. The Member role should be allowed to edit others' Lead Messages posts, using the edit Lead Message Form. If that does not solve the problem I'll take a closer look.

#1393813

I saw that it worked if I allowed set role to edit other users' forms. (could this be an issue if user 2 somehow ends up on user 1's lead?)

Also No user (except admin) should have access to the main leads directory
hidden link (CPT directory)

What must I do to adjust the Link to that of the Lead_name as well
(say a user updates name, i would like the slug to also update) -see attatched images

#1393875

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I saw that it worked if I allowed set role to edit other users' forms. (could this be an issue if user 2 somehow ends up on user 1's lead?)
If Lead 1 is submitted to Member 1, but Member 2 guesses the correct URL to Lead 1 and visits that page in the browser, then Member 2 could edit Lead 1 in this setup.

One way you could prevent this is by adding a conditional to the Lead template. The conditional could test the author of the parent Member post. If it's not the same as the current logged-in User, you would hide the Form to edit the Lead Message. If it is the same as the current logged-in User, you would show the Form to edit the Lead Message. Here is a code example of such a conditional:

[wpv-conditional if="( '[wpv-post-author item="@member-lead-message.parent" format="meta" meta="ID"]' eq '[wpv-current-user info="id"]' )"]
this lead's related member is my Member post, so insert the edit Lead Form shortcode here
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-author item="@member-lead-message.parent" format="meta" meta="ID"]' ne '[wpv-current-user info="id"]' )"]
this lead's related member is NOT my Member post. I am a different Member, so do not insert the edit Lead Form shortcode here
[/wpv-conditional]

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-author

#1397741

the 2nd conditional was showing when i tried this. remember the lead-message author would be the guest not the actual user/owner of the landing page that the message gets associated with.

whatever i put in the 2nd condition would show (ie: this is not one of your leads)

#1399033

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

the 2nd conditional was showing when i tried this...whatever i put in the 2nd condition would show (ie: this is not one of your leads)
Right, you would delete the second conditional if you want Guests to be able to edit the Lead Message. I didn't understand that was a requirement. A Guest User has no User ID and is never the author of any post. It is not possible for them to be the author of any post. The conditionals here would only work for Members or another logged-in User type. If you want a Guest User to be able to edit the post, then a different conditional is required...however, it will not help you display the edit Lead Message Form to one specific Guest. It will display the edit Lead Message Form to all Guests, because there is no differentiation between Guest users like this in WordPress. There is no built-in way to determine which Guest created the Lead Message.

[wpv-conditional if="( '[wpv-current-user info="ID"]' lt '1' )"]This is a Guest User[/wpv-conditional]

remember the lead-message author would be the guest not the actual user/owner of the landing page that the message gets associated with.
A Guest may have written and submitted this post in a Form, but that has no bearing on the WordPress post author concept. The WordPress post author is undefined if submitted by a Guest, because that Guest has no record in WordPress.In WordPress a Guest cannot be the post author of any post, as I've already mentioned.

#1399133

The only person who should be able to edit the lead would be the person who owns the attatched Landing page that the lead is associated with. Guests should not be able to edit, nor other users that are not associated with the landing page

ex: User 1 has landing page 1 (where guest submits form)
lead is associated with landing page 1 (owner is user 1)

guest and user 2 should not be able to see/edit the lead that is linked to user 1. That is their lead nobody elses

#1399231

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Okay I see, I have updated the conditional on the My Leads page to hide Lead Messages from Guest Users. Each Member should see his/her own Lead Messages.

Now on the single Lead Message page, I have updated the conditional to work with the post_id field you created, instead of relying on Toolset's post relationships:

[wpv-conditional if="( '[wpv-post-field name="wpcf-post_id" ]' eq '[wpv-view name="current-user-member-id"]' )"]
[cred_form form='lead-notes-form']
[/wpv-conditional]

Now the edit Form is only shown to the correct Member, not Guests or other Members. Can you take a look and let me know what needs improvement now?

#1399285

its functional enough at this moment, but is there a way to hide the lead to users that don't own the lead as well..

Ie user2 somehow enters the wrong slug

/leads/user1lead (hidden to user 2) but if user1 were to enter the slug it would show lead with edit form.

its usable as is, but this would be even better so unauthorized users wouldn't have a chance to see other user's leads.

#1399287

Also, is there a way to display the Leads as the "lead_name" instead of the post/title/slug

functionally it works fine as well (but i would prefer to show the lead_name) in the list. Makes it easier to sort through

#1399795

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

its functional enough at this moment, but is there a way to hide the lead to users that don't own the lead as well..
There isn't an easy way to restrict access to a complete URL like this unless the Users have different User Roles. Then you could apply a specific Access group to each Member's leads. However, I don't think this is appropriate in your case because you do not have a different role for each Member. Instead, you could use conditionals in the Single Lead Elementor Template to hide content, like I have implemented conditionals there to hide the edit post Form. The challenge is this means you have to use text editors to insert your content in Elementor, so the conditional shortcodes can also be added around the content.

Also, is there a way to display the Leads as the "lead_name" instead of the post/title/slug
Yes, you can edit this View to change the display of each result in the View: hidden link
Scroll down to the "Loop item in LEAD-MESSAGE-VIEW" to modify the contents of each result loop. Use the Fields and Views button to insert a custom field from the Lead Message post.