Skip Navigation

[Resolved] Add follow category button

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

Last updated by souhirB 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1210031

I want to add follow category button so user can subscribe to category , and create a page with view which only shows post from categories the user follow

#1210239

Hi, there's nothing exactly like this built-in to Toolset. You could create something like this with custom fields, a View filtered by term, an Edit User Form, and some custom code. It's a rather complex setup. Here's the general idea:
- Create a repeating text field on User profiles. This field will hold the slugs of each term followed by the User.
- Create an Edit User Form that includes a generic hidden field. Set the value of the hidden field to be the slug of the term you wish to follow. Remove the other visible inputs.
- Use conditional HTML to test the current User's custom field value. Show or hide the Edit User Form depending on whether or not the User's repeating field contains the term. If the User follows the term, hide the Form. If the User does not follow the term, show the Form. I can show you some examples if you need help with this.
- Use the Forms API hook cred_save_data to update the User's custom field values when the User submits the Form. I can show you some examples if you need help with this.
- Create a View of posts, filtered by term slug, where the slug is set by a Views shortcode attribute.
- Pass the custom field value for the current User into the View shortcode.
- In the View results, build the design for displaying matching posts.

#1228643

My issue is resolved now. Thank you!