Skip Navigation

[Resolved] Favorite Posts Feature

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

Last updated by Christian Cox 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1207342

Hello Christian, i'm trying to follow this old thread and failing.

https://toolset.com/forums/topic/favorites-view-conditional-button-on-post-add-to-remove-from-favorite-list/

Specifically:

- Create a form that edits the listing post type
- Remove all the inputs from this form except the submit button

The site is a business listing membership site. The post type I'm trying to add the favorite post feature to is "listings" which is already created with a form that has required fields. So when I create another form I cannot remove all fields.

I'm sure I'm confused somewhere here...

#1207691

So when I create another form I cannot remove all fields.
Hi, in the new Form builder you will have to switch to expert mode. Then you can manually edit the code to remove everything except the main Form shortcode, the Form messages shortcode, and the submit button shortcode. It will look something like this:

[credform]
	[cred_field field='form_messages' class='alert alert-warning']
	[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
[/credform]

Then you should be able to save the modifications to the Form.

#1208016

Thanks Christian. Another related (and possibly stupid) question. How would I target the button to style it in this format?

Note that when creating a filter I had no problem finding the selector for the button. I generally get it, but can't seem to do so with this form for favorites.

#1208709

Skip that last question. Instead, could you help me with the php required to implement the cred_save_data hook to add the User's ID to the repeating field when the form is submitted? I've been unable to find an example in the documentation or previous questions.

Thank You!

#1209078

Sure, I can help. Here's an example showing how you would add the current User's ID to a custom field:

add_action('cred_save_data_12345', 'add_user_favorite_cred',10,2);
function add_user_favorite_cred($post_id, $form_data)
{
  add_post_meta($post_id, 'wpcf-fieldslug', get_current_user_id(), false);
}

https://toolset.com/forums/topic/favorites-view/#post-579587