Skip Navigation

[Resuelto] Favorite Posts By Logged In User (Add To / Remove not working properly)

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I would like Users to be able to choose certain posts as favorites. They should also be able to remove them from favorites.

Solution:
Create a repeating numeric field on your post type called "favorites". This field will be updated to add the current User's ID when they select a favorite. When they unfavorite a post, this field will be updated to remove their ID.

Create a CRED form that allows you to modify the posts that can be favorited. Remove all the content from the CRED form and replace it with the following code:

[credform class='cred-form cred-keep-original']
 
   [wpv-conditional if="( [toolset_is_favorite id='[wpv-post-id]'] eq '1' )"]
        [cred_generic_field field='remove-favorite' type='hidden' class='']
         {
           "required":0,
           "validate_format":0,
           "default":"1"
          }
        [/cred_generic_field]
      [/wpv-conditional]
       
    [cred_field field='form_submit' value='Favorite' urlparam='' class='x-btn x-btn-global mam']
[/credform]

Add the following JavaScript to your CRED form's JS panel:

jQuery(window).bind("load", function() {
   jQuery( "form[id^='cred_form_368']").find("input[type='submit']").val(jQuery( "input[name='remove-favorite']").length ? "Remove from Favorites" : "Add to Favorites");
   }
)

This code will toggle between showing "Add to Favorites" and "Remove from Favorites" as the button name.

Add the following PHP to your child theme's functions.php file:

add_action('cred_save_data_368', 'sda_user_favorites',10,2);
function sda_user_favorites($post_id, $form_data) {
    if( isset($_REQUEST['remove-favorite']) ) {
        delete_post_meta($post_id, 'wpcf-favorites', get_current_user_id());
    } else {
        add_post_meta($post_id, 'wpcf-favorites', get_current_user_id(), false);
    }
}
 
/* Favorites shotcode for use as a conditional */
add_shortcode( 'toolset_is_favorite', 'toolset_is_favorite_func');
function toolset_is_favorite_func($atts)
{
  global $wpdb;
  $post_id = $atts['id'];
  $user_id = get_current_user_id();
  $favorites = $wpdb->get_results( "SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = $post_id AND meta_value = $user_id LIMIT 1");
  return sizeof($favorites) ? 1 : 0;
}

Be sure to add the toolset_is_favorite shortcode in Toolset > Settings > Frontend content > 3rd party shortcode arguments.

Place the CRED form in a View of posts, or in a Content Template for these posts.

Relevant Documentation: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created hace 6 años, 11 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 18 respuestas, tiene 3 mensajes.

Última actualización por Team DNK hace 6 años, 11 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#597468

Attention Christian Cox... Hello Christian, I came across two threads that outline a Toolset centric solution for favoriting posts, Quite Brilliant!

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

PART 2: https://toolset.com/forums/topic/favorites-view/

THE ISSUE
Everything seems to work brilliantly until I log out and back in as a different user. If I try to Favorite an already Favorited post as the new user, the button displays the correct Text (Add to Favorites) and when I press the button nothing appears to happen, it still displays (Add to Favorites). Further each button press is now adding the user ID to a new instance of the repeating field in the post on the WordPress admin editor. This also happens if I log back in as the first user, the desired functionality is now broken until I manually delete all the Favorite repeating field entries that are generated in the admin editor for the given post. Just so you are aware I tried changing the user roles to see if that had any affect and it does not.

Below is my setup and I am simply working with the default post type at this point and manually placing the CRED Button (Form) on my test posts via the WordPress content edit area page not a Toolset Posts Layout.

FUNTIONS.PHP FILE

/* Add favorites functionality to posts via Toolset CRED */
add_action('cred_save_data_368', 'sda_user_favorites',10,2);
function sda_user_favorites($post_id, $form_data) {
	if( isset($_REQUEST['remove-favorite']) ) {
    	delete_post_meta($post_id, 'wpcf-favorites', get_current_user_id());
	} else {
		add_post_meta($post_id, 'wpcf-favorites', get_current_user_id(), false);
	}
}

CUSTOM POST FIELD GROUP (Post)
Field group has only one field, a repeating (Selection set to: Allow multiple-instances of this field) number field named Favorites. This field group is assigned to Posts in the (Where to include this Field Group).

CRED POST FORM (Favorites)
The Settings...
-Edit existing Content
-Posts type connected to form
-Keep original status
-Display the post after visitor submits
-No redirect delay
-No other settings as I want the button to appear to update in real time.
NOTE: I would prefer that CRED would update the button name when using AJAX so the page would not have to be refreshed but this does not seem possible with current version of CRED.

The Content...

[credform class='cred-form cred-keep-original']

      [wpv-conditional if="( [types field='favorites'][/types] eq [wpv-current-user info='id'] )"]
        [cred_generic_field field='remove-favorite' type='hidden' class='']
         {
           "required":0,
           "validate_format":0,
           "default":"1"
          }
        [/cred_generic_field]
      [/wpv-conditional]
    [cred_field field='form_submit' value='Favorite' urlparam='' class='x-btn x-btn-global mam']

[/credform]

The Content JS Editor...

jQuery(window).bind("load", function() {
   jQuery( "form[id^='cred_form_368']").find("input[type='submit']").val(jQuery( "input[name='remove-favorite']").length ? "Remove from Favorites" : "Add to Favorites");
   })

In regards to the provided debug info, I have also tested this using the production versions of Types and Views. Thanks in advance, I am looking forward to being able to favorite posts via this amazing Toolset Centric solution.

Kind Regards,
Dave

#597503

Okay I'll try to get this sorted out for you. Without being able to access your development site, I'll need you to enable logs so we can see where things are breaking down. Go in your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:

define('WP_DEBUG', true);

Then add these lines, just before it says 'stop editing here':

ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

This will enable server logging. Add the following log statements to your cred_save_data hook:

add_action('cred_save_data_368', 'sda_user_favorites',10,2);
function sda_user_favorites($post_id, $form_data) {
error_log('favorites callback');    
if( isset($_REQUEST['remove-favorite']) ) {
error_log('isset, delete');
        delete_post_meta($post_id, 'wpcf-favorites', get_current_user_id());
    } else {
error_log('not set, add: ' . get_current_user_id());
        add_post_meta($post_id, 'wpcf-favorites', get_current_user_id(), false);
    }
}

Next, edit your CRED form and add some debugging information:

[credform class='cred-form cred-keep-original']
 Favorites: [types field='favorites'][/types]<br />
User: [wpv-current-user info='id']<br />
      [wpv-conditional if="( [types field='favorites'][/types] eq [wpv-current-user info='id'] )"]
        [cred_generic_field field='remove-favorite' type='hidden' class='']
         {
           "required":0,
           "validate_format":0,
           "default":"1"
          }
        [/cred_generic_field]
      [/wpv-conditional]
    [cred_field field='form_submit' value='Favorite' urlparam='' class='x-btn x-btn-global mam']
 
[/credform]

Finally, edit your JS to add some logs:

jQuery(window).bind("load", function() {
console.log('load event');
console.log('form length: ' + jQuery( "form[id^='cred_form_368']").length);
console.log('submit length: ' + jQuery( "form[id^='cred_form_368']").find("input[type='submit']").length);
console.log('remove length: ' + jQuery( "input[name='remove-favorite']").length);
   jQuery( "form[id^='cred_form_368']").find("input[type='submit']").val(jQuery( "input[name='remove-favorite']").length ? "Remove from Favorites" : "Add to Favorites");
   })

Now, go to wp-admin and remove all the favorites from this post to start over. Log in as User 1 and favorite the post. Then, log out and log back in as User 2. Go to the CRED form and copy the Favorites and User information on the screen. Paste that into your reply here. Open your browser's JavaScript console. Refresh the page and watch the console logs, copy and paste the results in your reply. Now try to favorite the post. Watch the console for any error messages, and copy and paste those here.

Then use FTP to browse the root directory of your site (usually the same directory where wp-content can be found) and find the file "error_log.txt". Copy the contents of that file into your reply.

#597774

Hello Christian... Thank you for your assistance with this. Below I did my best to provide you with what you requested. Seems there may of been a syntax error in the code you provided and I was not able to track down the requested log file. Seems like it might be simpler to pop what I had provided into a testing site and see if you get the same results.

STEP 1: I added the four lines of code to the wp-config file right before the "/* That's all, stop editing! Happy blogging. */" section. My file did not already have a line "define(‘WP_DEBUG’, false);".

STEP 2: Updated the functions.php file with the provided code but could not save it due to syntax error, I had to delete the "." on line 8 right before "get_current_user_id".

STEP 3: Here is the info copied from the post after favoriting as user #1, logging out and then logging back in as user #2.
Favorites: 1
User: 2

STEP 4: Here is the info from the javascript Console after refreshing the post page when logged in as user #2.
[Log] JQMIGRATE: Migrate is installed, version 1.4.1 (jquery-migrate.min.js, line 2)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (parsley.js.map, line 0)
[Log] load event (post-six, line 313)
[Log] form length: 1 (post-six, line 314)
[Log] submit length: 1 (post-six, line 315)
[Log] remove length: 0 (post-six, line 316)

STEP 5: After trying to Favorite the post as user #2 I got a browser prompt modal "There was an error while submitting the form" and no log Javascript Console Log change. I tried refreshing the browser again and it updated to what you see below.
[Log] JQMIGRATE: Migrate is installed, version 1.4.1 (jquery-migrate.min.js, line 2)
[Log] load event (post-six, line 313)
[Log] form length: 1 (post-six, line 314)
[Log] submit length: 1 (post-six, line 315)
[Log] remove length: 0 (post-six, line 316)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (parsley.js.map, line 0)

STEP 6: Dug through the main site folders in search of the "error_log.txt" file but could not find it. In the root directory there are a lot of server logs but not sure which one would contain the info you are looking for.

Kind Regards,
Dave

#597795
Screenshot_01.png

Hello Again Christian... I went back over everything again and perhaps I did not save after editing the wp-config file in my code editor. After saving I now see the "error_log.txt" file, apologies if this is a goof on my end. Below are the logs from the file after redoing all the steps in the previous thread post. Also it looked like everything was the same as I previously reported.

In addition to the contents of the Error Log file pasted below is a screenshot that represents the edited line of code in the functions.php file which is also the line 138 showing up as an error in the Error Log.

ERROR LOG
[11-Dec-2017 17:23:49 UTC] favorites callback
[11-Dec-2017 17:23:49 UTC] isset, delete
[11-Dec-2017 17:24:13 UTC] favorites callback
[11-Dec-2017 17:25:13 UTC] favorites callback
[11-Dec-2017 17:25:13 UTC] PHP Warning: error_log(): TCP/IP option not available! in /srv/users/serverpilot/apps/0-test-hybridsite/public/wp-content/themes/astra/functions.php on line 138

Kind Regards,
Dave

#597844

Okay yes I made a typo, this line had an extra comma. Here's the correct code:

error_log('not set, add: ' . get_current_user_id());

Please run through the procedure once more with this fixed. You should no longer see the "There was an error while submitting the form" message.

#597853

Hi Christian... Here is the info after making the change to the functions.php file.

STEP 3: Info copied from the post after favoriting as user #1, logging out and then logging back in as user #2.
Favorites: 1
User: 2

STEP 4: Info from the javascript Console after refreshing the post page when logged in as user #2.
[Log] JQMIGRATE: Migrate is installed, version 1.4.1 (jquery-migrate.min.js, line 2)
[Log] load event (post-six, line 313)
[Log] form length: 1 (post-six, line 314)
[Log] submit length: 1 (post-six, line 315)
[Log] remove length: 0 (post-six, line 316)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (parsley.js.map, line 0)

STEP 5: Info after Favoriting the post as user #2 and refreshing (No browser prompt this time).
[Log] JQMIGRATE: Migrate is installed, version 1.4.1 (jquery-migrate.min.js, line 2)
[Log] load event (post-six, line 313)
[Log] form length: 1 (post-six, line 314)
[Log] submit length: 1 (post-six, line 315)
[Log] remove length: 0 (post-six, line 316)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (parsley.js.map, line 0)

STEP 5 WITH REFRESH: Thought I would send this just in case you needed to see it after a refresh.
[Log] JQMIGRATE: Migrate is installed, version 1.4.1 (jquery-migrate.min.js, line 2)
[Error] Failed to load resource: the server responded with a status of 404 (HTTP/2.0 404) (parsley.js.map, line 0)
[Log] load event (post-six, line 313)
[Log] form length: 1 (post-six, line 314)
[Log] submit length: 1 (post-six, line 315)
[Log] remove length: 0 (post-six, line 316)

STEP 6: Info from "error_log.txt" file after all above steps have been completed.
[11-Dec-2017 20:59:12 UTC] favorites callback
[11-Dec-2017 20:59:12 UTC] not set, add: 1
[11-Dec-2017 21:01:55 UTC] favorites callback
[11-Dec-2017 21:01:55 UTC] not set, add: 2

#597870

I remember now why this won't work, the conditional is inaccurate. I created a shortcode to fix that, and we implemented it later on in that ticket. Please add this shortcode to your functions.php file:

add_shortcode( 'toolset_is_favorite', 'toolset_is_favorite_func');
function toolset_is_favorite_func($atts)
{
  global $wpdb;
  $post_id = $atts['id'];
  $user_id = get_current_user_id();
  $favorites = $wpdb->get_results( "SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = $post_id AND meta_value = $user_id LIMIT 1");
  return sizeof($favorites) ? 1 : 0;
}

This shortcode accepts an id parameter and determines whether or not the current user has favorited that post. It returns 1 if yes, or 0 if no.

Go to Toolset > Settings > Front-end content tab and type "toolset_is_favorite" in the Third-party shortcode arguments input field, then press Return or Enter. Now you can use this shortcode in the conditional:

[wpv-conditional if="( [toolset_is_favorite id='[wpv-post-id]'] eq '1' )"]
        [cred_generic_field field='remove-favorite' type='hidden' class='']
         {
           "required":0,
           "validate_format":0,
           "default":"1"
          }
        [/cred_generic_field]
      [/wpv-conditional]
#597921
Third-party Shortcode .png

Hi Christian... I think I see what you are doing with this new code for the functions.php file but after inserting it along with the new conditional, things still are not working correctly. The toggle functionality is no longer working and even when I am just in User # 1, the button is adding instances to the Favorites field.

The field and form settings are as the have been and I entered the "toolset_is_favorite" into the Third-party shortcode area of Toolset Settings so I must have something misconfigured with the code somewhere. Below is all the code I am using in each of the areas, apologies if I am missing something obvious, appreciate all your help with this.

FUNTIONS.PHP FILE

/* Add favorites functionality to posts via Toolset CRED */
add_action('cred_save_data_368', 'sda_user_favorites',10,2);
function sda_user_favorites($post_id, $form_data) {
    if( isset($_REQUEST['remove-favorite']) ) {
        delete_post_meta($post_id, 'wpcf-favorites', get_current_user_id());
    } else {
        add_post_meta($post_id, 'wpcf-favorites', get_current_user_id(), false);
    }
}

/* Favorites shotcode for use as a conditional */
add_shortcode( 'toolset_is_favorite', 'toolset_is_favorite_func');
function toolset_is_favorite_func($atts)
{
  global $wpdb;
  $post_id = $atts['id'];
  $user_id = get_current_user_id();
  $favorites = $wpdb->get_results( "SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = $post_id AND meta_value = $user_id LIMIT 1");
  return sizeof($favorites) ? 1 : 0;
}

CRED POST FORM - CONTENT

[credform class='cred-form cred-keep-original']

	[wpv-conditional if="( [toolset_is_favorite id='[wpv-post-id]'] eq '1' )"]
        [cred_generic_field field='remove-favorite' type='hidden' class='']
         {
           "required":0,
           "validate_format":0,
           "default":"1"
          }
        [/cred_generic_field]
      [/wpv-conditional]
    
    [cred_field field='form_submit' value='Favorite' urlparam='' class='x-btn x-btn-global mam']

[/credform]

CRED POST FORM - JS EDITOR

jQuery(window).bind("load", function() {
   jQuery( "form[id^='cred_form_368']").find("input[type='submit']").val(jQuery( "input[name='remove-favorite']").length ? "Remove from Favorites" : "Add to Favorites");
   }
)
#598621

Hello Christian... Noticed that Toolset was down yesterday for maintenance when I checked to see if you had responded to my previous post. Also noticed that this thread is displaying the wrong support persons image in My Support Tickets list, just want to confirm you are still connected to this thread and still supporting me with it?

#598943

Shane
Supporter

Idiomas: Inglés (English )

Zona horaria: America/Jamaica (GMT-05:00)

Hi Dave,

I must apologize for the delay in response.

Christian is currently on vacation but will be back in a few days. Would you like me to continue assisting though I would need to get up to speed on the ticket or would you prefer waiting until Christian is back.

Please let me know.
Thanks,
Shane

#599007

Hi Shane... Please tag this thread for response by Christian when he returns.

Thanks,
Dave

#599964

Where exactly are things breaking down? If you'd like to provide a Duplicator clone of your site I can try to work on that and see where things are going wrong. Otherwise, please try these steps:

- Replace the log statements in your PHP code
- Delete posts and favorites and start again with new posts
- Add each shortcode to the CRED form content individually, and turn on debug mode in the conditional:

[credform class='cred-form cred-keep-original']
   ***Post ID: [wpv-post-id]
   ***Is favorite: [toolset_is_favorite id='[wpv-post-id]']
    [wpv-conditional if="( [toolset_is_favorite id='[wpv-post-id]'] eq '1' )" debug="true"]
        [cred_generic_field field='remove-favorite' type='hidden' class='']
         {
           "required":0,
           "validate_format":0,
           "default":"1"
          }
        [/cred_generic_field]
      [/wpv-conditional]
     
    [cred_field field='form_submit' value='Favorite' urlparam='' class='x-btn x-btn-global mam']
 
[/credform]

- Favorite the post as different Users
- Is Post ID correct on the CRED form in all cases?
- Is favorite correct on the CRED form in all cases?
- Copy and paste the conditional debug output here for me to review
- Copy and paste the PHP logs here for me to review

#600056
Admin User After Favorite.png
Second User After Favorite.png
Post Edit Screen.png

Hello Christian... Here are the logs and I hope we can work through this without the duplicator package. If we reach a dead end I will need to set up a special server environment for beta testing as I have to keep things separate for security reasons.

Did as you asked and I also created a new post. Further I have once again included all code so you have everything in front of you. There are a couple screenshots and you will see that there is also an error at the top of the post just below the title area.

WP-CONFIG FILE

/* Testing mode with log as per Christian */
define('WP_DEBUG', true);
ini_set('log_errors',TRUE);
ini_set('error_reporting', E_ALL);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');

FUNTIONS.PHP FILE

/* Add favorites functionality to posts via Toolset CRED */
add_action('cred_save_data_368', 'sda_user_favorites',10,2);
function sda_user_favorites($post_id, $form_data) {
    if( isset($_REQUEST['remove-favorite']) ) {
        delete_post_meta($post_id, 'wpcf-favorites', get_current_user_id());
    } else {
        add_post_meta($post_id, 'wpcf-favorites', get_current_user_id(), false);
    }
}

/* Favorites shotcode for use as a conditional */
add_shortcode( 'toolset_is_favorite', 'toolset_is_favorite_func');
function toolset_is_favorite_func($atts)
{
  global $wpdb;
  $post_id = $atts['id'];
  $user_id = get_current_user_id();
  $favorites = $wpdb->get_results( "SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = $post_id AND meta_value = $user_id LIMIT 1");
  return sizeof($favorites) ? 1 : 0;
}

CRED POST FORM - CONTENT

[credform class='cred-form cred-keep-original']

   ***Post ID: [wpv-post-id]<br />
   ***Is favorite: [toolset_is_favorite id='[wpv-post-id]']<br />

    [wpv-conditional if="( [toolset_is_favorite id='[wpv-post-id]'] eq '1' )" debug="true"]
        [cred_generic_field field='remove-favorite' type='hidden' class='']
         {
           "required":0,
           "validate_format":0,
           "default":"1"
          }
        [/cred_generic_field]
      [/wpv-conditional]
      
    [cred_field field='form_submit' value='Favorite' urlparam='' class='x-btn x-btn-global mam']
  
[/credform]

CRED POST FORM - JS EDITOR

jQuery(window).bind("load", function() {
   jQuery( "form[id^='cred_form_368']").find("input[type='submit']").val(jQuery( "input[name='remove-favorite']").length ? "Remove from Favorites" : "Add to Favorites");
   }
)

ERROR LOG (Deleted any old logs so this is just the info from time of test)
[18-Dec-2017 23:54:31 UTC] WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = 409 AND meta_value = 1 LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/astra/single.php'), get_template_part, locate_template, load_template, require('/themes/astra/template-parts/content-single.php'), astra_entry_content_single, do_action('astra_entry_content_single'), WP_Hook->do_action, WP_Hook->apply_filters, astra_entry_content_single_template, get_template_part, locate_template, load_template, require('/themes/astra/template-parts/single/single-layout.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, CRED_Helper::credFormShortcode, CRED_Helper::cred_form, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->build_form, wpv_do_shortcode, apply_filters('wpv-pre-do-shortcode'), WP_Hook->apply_filters, WPV_Frontend_Render_Filters::wpv_pre_do_shortcode, wpv_parse_content_shortcodes, do_shortcode, preg_replace_callback, do_shortcode_tag, toolset_is_favorite_func
[18-Dec-2017 23:54:43 UTC] WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = 409 AND meta_value = 1 LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('wp_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, CRED_Form_Builder_Base->init, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->build_form, wpv_do_shortcode, apply_filters('wpv-pre-do-shortcode'), WP_Hook->apply_filters, WPV_Frontend_Render_Filters::wpv_pre_do_shortcode, wpv_parse_content_shortcodes, do_shortcode, preg_replace_callback, do_shortcode_tag, toolset_is_favorite_func
[18-Dec-2017 23:54:44 UTC] WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = 409 AND meta_value = 1 LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/astra/single.php'), get_template_part, locate_template, load_template, require('/themes/astra/template-parts/content-single.php'), astra_entry_content_single, do_action('astra_entry_content_single'), WP_Hook->do_action, WP_Hook->apply_filters, astra_entry_content_single_template, get_template_part, locate_template, load_template, require('/themes/astra/template-parts/single/single-layout.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, CRED_Helper::credFormShortcode, CRED_Helper::cred_form, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->build_form, wpv_do_shortcode, apply_filters('wpv-pre-do-shortcode'), WP_Hook->apply_filters, WPV_Frontend_Render_Filters::wpv_pre_do_shortcode, wpv_parse_content_shortcodes, do_shortcode, preg_replace_callback, do_shortcode_tag, toolset_is_favorite_func
[18-Dec-2017 23:57:09 UTC] WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = 409 AND meta_value = 2 LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/astra/single.php'), get_template_part, locate_template, load_template, require('/themes/astra/template-parts/content-single.php'), astra_entry_content_single, do_action('astra_entry_content_single'), WP_Hook->do_action, WP_Hook->apply_filters, astra_entry_content_single_template, get_template_part, locate_template, load_template, require('/themes/astra/template-parts/single/single-layout.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, CRED_Helper::credFormShortcode, CRED_Helper::cred_form, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->build_form, wpv_do_shortcode, apply_filters('wpv-pre-do-shortcode'), WP_Hook->apply_filters, WPV_Frontend_Render_Filters::wpv_pre_do_shortcode, wpv_parse_content_shortcodes, do_shortcode, preg_replace_callback, do_shortcode_tag, toolset_is_favorite_func
[18-Dec-2017 23:57:19 UTC] WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = 409 AND meta_value = 2 LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('wp_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, CRED_Form_Builder_Base->init, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->build_form, wpv_do_shortcode, apply_filters('wpv-pre-do-shortcode'), WP_Hook->apply_filters, WPV_Frontend_Render_Filters::wpv_pre_do_shortcode, wpv_parse_content_shortcodes, do_shortcode, preg_replace_callback, do_shortcode_tag, toolset_is_favorite_func
[18-Dec-2017 23:57:19 UTC] WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = 409 AND meta_value = 2 LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/astra/single.php'), get_template_part, locate_template, load_template, require('/themes/astra/template-parts/content-single.php'), astra_entry_content_single, do_action('astra_entry_content_single'), WP_Hook->do_action, WP_Hook->apply_filters, astra_entry_content_single_template, get_template_part, locate_template, load_template, require('/themes/astra/template-parts/single/single-layout.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, CRED_Helper::credFormShortcode, CRED_Helper::cred_form, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->build_form, wpv_do_shortcode, apply_filters('wpv-pre-do-shortcode'), WP_Hook->apply_filters, WPV_Frontend_Render_Filters::wpv_pre_do_shortcode, wpv_parse_content_shortcodes, do_shortcode, preg_replace_callback, do_shortcode_tag, toolset_is_favorite_func
[18-Dec-2017 23:58:23 UTC] WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = 409 AND meta_value = 2 LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('wp_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, CRED_Form_Builder_Base->init, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->build_form, wpv_do_shortcode, apply_filters('wpv-pre-do-shortcode'), WP_Hook->apply_filters, WPV_Frontend_Render_Filters::wpv_pre_do_shortcode, wpv_parse_content_shortcodes, do_shortcode, preg_replace_callback, do_shortcode_tag, toolset_is_favorite_func
[18-Dec-2017 23:58:23 UTC] WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = 409 AND meta_value = 2 LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/astra/single.php'), get_template_part, locate_template, load_template, require('/themes/astra/template-parts/content-single.php'), astra_entry_content_single, do_action('astra_entry_content_single'), WP_Hook->do_action, WP_Hook->apply_filters, astra_entry_content_single_template, get_template_part, locate_template, load_template, require('/themes/astra/template-parts/single/single-layout.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, CRED_Helper::credFormShortcode, CRED_Helper::cred_form, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->build_form, wpv_do_shortcode, apply_filters('wpv-pre-do-shortcode'), WP_Hook->apply_filters, WPV_Frontend_Render_Filters::wpv_pre_do_shortcode, wpv_parse_content_shortcodes, do_shortcode, preg_replace_callback, do_shortcode_tag, toolset_is_favorite_func
[18-Dec-2017 23:59:12 UTC] WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = 409 AND meta_value = 1 LIMIT 1 made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/astra/single.php'), get_template_part, locate_template, load_template, require('/themes/astra/template-parts/content-single.php'), astra_entry_content_single, do_action('astra_entry_content_single'), WP_Hook->do_action, WP_Hook->apply_filters, astra_entry_content_single_template, get_template_part, locate_template, load_template, require('/themes/astra/template-parts/single/single-layout.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, CRED_Helper::credFormShortcode, CRED_Helper::cred_form, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->build_form, wpv_do_shortcode, apply_filters('wpv-pre-do-shortcode'), WP_Hook->apply_filters, WPV_Frontend_Render_Filters::wpv_pre_do_shortcode, wpv_parse_content_shortcodes, do_shortcode, preg_replace_callback, do_shortcode_tag, toolset_is_favorite_func

#600292

Look at this query:

$favorites = $wpdb->get_results( "SELECT * FROM wp_postmeta WHERE ... );

And the error:

WordPress database error Table '0-test-hybridsite-wp-gDE6T0ir.wp_postmeta' doesn't exist for query SELECT * FROM wp_postmeta WHERE ...

This tells us that the wp_postmeta table does not exist. Are you using a different DB prefix? If so, you must change wp_postmeta in the SELECT statement to match your DB's postmeta table name.

#600310

Hi Christian... Thank you, I completely missed that, my prefix included a string of numbers and letters after the wp_ and with that adjustment the core functionality seems to be working as expected.

If my intent is to deploy this on a site that will have over 10,000 users who will be favoriting upwards of 50 custom post type posts each, should I consider your new BETA Types and Views Post Relationship approach instead of using a repeating field?

If so what steps need to be taken to do this?

Kind Regards,
Dave