Skip Navigation

[Resolved] Access-levels on posts

This support ticket is created 6 years, 2 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)

Author
Posts
#1118973
flow.JPG

Hi, i need to reference to ticket #1117632
And about user roles.

I have a Posttype called "Company" in this like to register a cople of companies there they have their presentation.
to this posttype i will connect "one-to-many" relationships. 1 relationsip is Ads, one is for products and one can be something else. not desided yet.
I will also make a front-end form so they can register from fromt-end.

But the thing is , i really cant get it how to set the access-level witht he "Access module" so user for an example "Company A" Let say that i have a userRole "CompanyUser" a company register an need to get access to its content

User-A and can only access his content on Post "Company A" and the Products connected to that post "Company A"
User-B can NOT access User-A's content.

Let say i have a form on front end where they register their company and information about that company. also add what taxanomi they like to have and so on... this will be a post "Company A" in posttype "Companies"
And when register, they can log on with thier credentials and access their information an also add "products" that only connects to the post "Company A"

Are you with me ?

What i can figuer ut is that i only can set one role to the whole posttype Copmpanies. so im stuck.

Does my flow make sence ? 🙂
(se attacehed)

#1119193

I have come so far that i have the form to add a post to "foretag"
hidden link

And i also have the form to add a user:
hidden link

But HOW do i connect these two forms? In the best world i would ike to have ONE form that do both at the same time.
And the "add-new-content" shall ONLY be accessible when step 1 is done, created a user.

#1119296

But HOW do i connect these two forms? In the best world i would ike to have ONE form that do both at the same time.
Hi, a Toolset Form only performs one of these operations:
- Create a post of some type
- Edit a post of some type
- Create a User account
- Edit a User account
So the best world scenario is not possible without a significant amount of custom code. Generally at least two Forms are required to create a User and create a post of some kind.

And the "add-new-content" shall ONLY be accessible when step 1 is done, created a user.
This part is fairly simple to implement using conditional HTML, depending on the current User's ID. A guest User will not have a real ID set yet, so you can do something like this:

[wpv-conditional if="( '[wpv-current-user info="id"]' gte '1' )"]
Registered Users will see this Form:<br />
[cred_form form="some-form-slug"]
[/wpv-conditional]
[wpv-conditional if="( '[wpv-current-user info="id"]' lt '1' )"]
Guest Users will only see this text, not the Form.<br />
[/wpv-conditional]

More information about conditional HTML and the wpv-current-user shortcode are available in our docs:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-current-user
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

I also think it will be helpful for you to review this document, which discusses different ways you can relate posts and Users:
https://toolset.com/documentation/user-guides/how-to-create-custom-searches-and-relationships-for-users/

#1119766

Thank you very much!
I will check this out asap and try this steps!
I read the last post you gave me, and thats exaxctly what i like to do with my project.

Its OK that the user must first be created and then hi/her can add/edit the content/posts that belongs to that user-account.

I give it a try an post back to you.

i belive the snippletcode is meant to be in the top on the page "add-new-content" before the form-code ?

#1119776

EDIT: Im so slow... I was logged in already... Tried it in another Browser - works like a charm 😉

i have come to the "login-form" and im stuck. i use the shortcode to make the Wp-login-form visable.
I know that its the wordpress own loginform, but it does not shows up
hidden link

shortcode: [wpv-login-form redirect_url="hidden link" allow_remember="true"]

what do i miss ?

#1119827

I have now made it so:
i register a user - no problem, works!
I redirect the user to post "add-new-content" with your snipplet. - works
- But how do i connect this form to that user ?

i have tried walk this guide, but i dont get the step how the form on "add-new-content" is fetching the user-id so that information is conncted only to that user.
https://toolset.com/documentation/user-guides/how-to-create-custom-searches-and-relationships-for-users/

Im my case this would be the user connect to contracter 🙂
I will then create a new posttype with more info as "showcase" but in my case posttype: "Offers"

#1119916

I think I've come a little longer now.
but I get this error message when I create "edit form"

I want the user to edit what he / she has added.

I have followed the guide, but it takes a stop there.

"Create a new Layout that will include the editing form. You can start from scratch or copy the template you use to display the content and modify it."

Please login if you like

#1120671
help.JPG

Hello,
I cant get this to work as i like. Please Help and advice.
Almost thou.

If you see the flow on the site. Go to LoginA and log in with "ProPatrik" and psw "123456"

You come to that companies "startpage" ("my-content")
ProPatrik AB (company)
And two offers below. (these i have added from backend "självservice.se" and "nyttigaremat.se")

If you click on "ProPatrik AB" you get to that company presentation-page, but two differnet items. They has the exact same view with filter "Only show auther post..." etc.
The thing is, that those two items on company presentation-page, has no company added as a "Relationship". but still shows up with that view above?

And those two "självservice.se" and "nyttigaremat.se" shows up on ALL post.... thats not correct, i think.
Becuse:
if i surf to "hidden link" the two items that was created via "add offer"-button on the company startpage (my-content). hidden link , shows upo and that seems correct.
Why doues then "självservice.se" and "nyttigaremat.se" shows up on the company page "my content"

I only want that item that is created by that user/company is shown on thet company-presentation-page.

I really cant get that to work from back end ether. Becous i need to be able to add items from backend and connect items to the company without to be logged on as the unique user to that company.

Please help me sort this out and im soon done 🙂

#1120794

The thing is, that those two items on company presentation-page, has no company added as a "Relationship". but still shows up with that view above?
That is correct, because there is no Post Relationship Query Filter added to this View: hidden link
The View is filtered by post author, and both of these Offers have the author ProPatrick. If you want to filter by post relationship, you must add a Post Relationship Query Filter. Remember that Post Relationships and post author are two different ways to connect posts and users, and the search filters work differently.

I only want that item that is created by that user/company is shown on thet company-presentation-page.
The Procedit AB post author is "patrik", and this user is also the author of these offers: "självservice.se" and "nyttigaremat.se". Notice that "AAAA" and "Nytt test" do not appear on the "patrik" company presentation page. They only appear on the "ProPatrik AB" company presentation page. So I think this is working as expected based on your View's query filter.

Becous i need to be able to add items from backend and connect items to the company without to be logged on as the unique user to that company.
You can do this as an administrator by setting the post author in wp-admin. Go to Toolset > Post Types and edit the Offer post type. In the "Sections to display when editing Offers" section, there is a checkbox that will turn on the "Author" field. Turn that on, and save the post type. Now when you edit Offers, you can choose any User to be the author of the Offer post.

Or, you can use Post Relationships to link Offers and Companies, then use a post relationship filter in your View of Offers on the Company presentation page. Let me know if you still have pending questions.

#1120926
a1.JPG

i did get the company-presentaion-page to work as i like. all items shows up.
* hidden link

But not on the "hidden link" that would be the same data.
It shows the Company correct, but the items dont shows up.
I dont get it why?

And when i use "add offer" from the page "Content of your company" the item is not assigned to that company it is refererd from. I cant get this to work!

And also the problem to make "edit-forms" och both items and company.
When i try to add post-Edit-link i get this error:
"Create a new Layout that will include the editing form. You can start from scratch or copy the template you use to display the content and modify it."

And on the item-page, why cant i fetch the companyname ?

Isnt it better if Offer items is connected to Companies post only and not user. If the user is logged on, he/she ses his/hers itmes on other companies...

As you also can see at the image, its not correct ?

What do i do wrong ??!: )

Can you please make it work? ?

EDIT:
I think that "my content" is the correct one.
I have changed all the titles to (Auth: XXX) so i can se it live. And my contetnt is correct.
the Presentaion-page is wrong. it shows all users items and not the selected companys items

#1120947

I have now changed it

If i use "Select posts with the author the same as the page where this View is shown"
it seams to be correct on both pages.
My content, and Presentation.

Now there is a news issue.

IF one user, ex "Patrik" that is administrator, adding a item from backend, the author is set to "patrik"
and the item will show up wrong.

The offers need always be connected to the company and not the user.

I think im getting lost i all querys...

So, how do i do the postform that add the item fetch the company-connection?

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

https://toolset.com/forums/topic/connect-two-different-post-types/

#1120977

edit to #1120947

I have find one more issue.
When a user register from Frontend they get the correct Role (CompanyUser) - thats correct.
But then i cant add this as a Auther. Only administrators can be authors on posts.

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

https://toolset.com/forums/topic/custom-user-role-is-not-included-in-author-field/

#1120996

I think im getting lost i all querys...
Yes, I think I am a bit lost too, sorry! Please note that our support policy is to address one issue per ticket: https://toolset.com/toolset-support-policy/
Feel free to open as many tickets as you need, but include only one issue per ticket. This helps us keep the forum organized, and helps other users find answers to similar questions. I have split your two most recent questions into separate tickets so we can continue to discuss those issues.