Saltar navegación

[Resuelto] Create a User Profile preference to permit profile view as per user role.

This support ticket is created hace 5 años, 1 mes. 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por Luo Yang hace 5 años, 1 mes.

Asistido por: Luo Yang.

Autor
Mensajes
#1375227

I'm am trying to allow users to choose who has access to their profiles via a radio or check box selection that is changeable on their profile page.

Example: User type A only can choose to have User role B and user role C to view their profile. Or just User role B.

I would also like the user to have the ability to choose whether the profile is shown to guest, only to logged in, or hidden from everyone.

What would be the best way to accomplish this?

Thanks!

#1375293

Hello,

There isn't such kind of built-in feature within Toolset, you can consider this:
1) Create a custom post type "user-profile", setup custom fields in this post type, use this custom post as user profile page, see our document:
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/

2) Use Access group to control read access to "user-profile" posts, see our document:
https://toolset.com/documentation/user-guides/limiting-read-access-specific-content/
Access allows you to limit the front-end (read) access to specific pages, posts or custom types. You can define who can access the full content and what others, without full access.

When you edit a page or a post, you will see the Post group metabox in the WordPress Block Editor’s right sidebar, under the Document tab. see screenshot:
https://toolset.com/wp-content/uploads/2019/09/toolset-access-post-group-metabox-block-editor.png

#1375921

I'm not clear. I may be missing something. I see this is a wp admin field selection. The Users with the Profile page do not have the ability to edit in the back end? How can I create taxonomy choices on frontend profile forms and edit forms?

I am looking for something like a custom field selection on the user's create profile form and edit profile form like this:

"Who can see my User A (role) profile?"

| | Public (Guests)
| | User Role B
| | User Role C

I tried to use taxonomy, but that doesn't show selections on the front end...just a blank space. I became confused about all the access settings. I need help.

Thanks!

#1376017

I was able to get the taxonomy to show on front end by changing to Hierarchical view.

Is there some way I can connect permissions to the taxonomy?

Alternatively, is there a way the user can hide or unpublish the profile from the edit profile page?

I could do something like this: https://toolset.com/forums/topic/the-single-post-template-file/ to hide specific content fields.

Thanks!

#1376071

For the new question:

Is there some way I can connect permissions to the taxonomy?

Please elaborate the question with more details:
How do you setup the custom taxonomy?
Are we talking about a custom post type "user-profile" with a custom taxonomy "Who can see my User A (role) profile"?

If it is, you might consider custom codes, for example, create a custom shortcode with a PHP function:
https://codex.wordpress.org/Function_Reference/add_shortcode

In this PHP function, compare current logged-in user's role with current post's terms of taxonomy "Who can see my User A (role) profile", for example:
https://stackoverflow.com/questions/39593273/user-roles-shortcode
https://developer.wordpress.org/reference/functions/wp_get_object_terms/

For your reference.

#1376645

The goal here is to have the User decide who sees their profile. The custom taxonomy is connected to the user profile CPT. The user will select the taxonomy for the user role allowed to view profile. Example Taxonomy = User Role Permission, like Public = Guest, Taxonomy B = User role B Permission.

Re add_shortcode: Doesn't Access have the ability to use shortcodes to show/hide content? I'm not understanding why creating add_shortcode would be needed.

I'm not seeing how the PHP is related to the user roles. Probably way beyond my ability.

#1376817

Yes, in your case, it requires custom codes, if you needs more assistance for it, please provide a test site with same problem, also point out the problem page URL, and where I can edit your PHP codes, I can setup a demo for you.