Skip Navigation

[Resolved] Limit custom post access to author only

This support ticket is created 6 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 8 replies, has 2 voices.

Last updated by markR-11 6 years ago.

Assisted by: Shane.

Author
Posts
#1135900

I am trying to limit a custom post type to only be accessible on the front-end by the author of the post. The custom post type is called 'Receipts', so as you an imagine, it is a receipt of an order. I use an external process to add the post + post meta, and that works fine. The author is also set correctly to match the user who paid for their subscription. The problem comes in that although the view is filtered in their members dashboard to only show their receipts, if they were given the link to another users receipt, they could see it.

Ideally only Administrators (or another role I set) and the author of the post should be able to view their invoice.

Tried following this, but doesn't get into providing access to owner/author of post only:
https://toolset.com/documentation/user-guides/limiting-read-access-specific-content/

Any help would be appreciated!

#1136202

Shane
Supporter

Languages: English (English )

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

Hi Mark,

Thank you for contacting our support forum.

If you have our Access plugin installed, then you should be able to remove the preview any option from the user role of that CPT.

Could you check and let me know if this works ?

Thanks,
Shane

#1137440
screen-receipt-access.PNG

Hey there Shane,

Unfortunately that doesn't seem to work. I have it unchecked for Preview Any, but everybody / guests can all access receipts....

See screenshot -- any other thoughts? If you are around tomorrow (well today, haha) then let me know if we can connect.

Regards,
Mark

#1137798

Shane
Supporter

Languages: English (English )

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

Hi Mark,

Would you mind allowing me to have admin access to the site so that I can investigate this one further for you ?

The private fields have been enabled for your next response as well as let me know the role.

Thanks,
Shane

#1137840

Shane
Supporter

Languages: English (English )

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

Screenshot 2018-10-31 at 3.57.10 PM.png

Hi Mark,

I tried to access this page but i'm getting a 404

Could you try this and let me know when I can log in.

Thanks,
Shane

#1137850

Hey Shane,

Sorry, remove the 'https', replace with 'http'.

Regards,
Mark

#1138381

Shane
Supporter

Languages: English (English )

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

Hi Mark,

I did some checks on this and it seems there isn't a way to restrict the users to not be able to access other users pages.

Since the user gets a general role, it doesn't apply the roles to the individual users.

I know you can only allow the current user's post to only show up with views but you're not able to restrict them from accessing the other user's posts if they get a direct link.

Some custom coding will need to be used to achieve something this specific.

Thanks,
Shane

#1139747

Hey Shane,

Thanks for that -- any thoughts from you or your team on an approach to this? It'd be great if I could request this as a feature request, might be a nice addition to the Access plugin.

Thanks,
Mark

#1140138

Hey there Shane,

Thanks for your help -- I worked around this by just utilizing the post status, set it to private so only the post author can see it, and then updated the view query to look for those that are marked private. This seems to prevent the URL from being accessed by another user that is not the author, without getting overly complicated.

Thanks,
Mark