• Resolved gayathricolundalur

    (@gayathricolundalur)


    Need help customizing the serving size of recipes based on user meta field which holds a logged in user’s serving size preference. For example: if the recipe is written for 2 servings and the user’s serving size meta data (custom data) is set to 4. I want all recipes to display for 4 servings when the user is logged in.

    How can I accomplish this?

    https://www.ads-software.com/plugins/wp-ultimate-recipe/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Brecht

    (@brechtvds)

    Hi there,

    Try adding the following code to your theme’s functions.php file (but make sure to change wpurp_servings to whatever metakey you’re using on your website):

    function wpurp_output_recipe( $template, $recipe )
    {
    $servings = get_user_meta( get_current_user_id(), ‘wpurp_servings’, true);
    if( $servings ) {
    $template .= ‘<script>jQuery(document).ready(function() { jQuery(“.wpurp-recipe-servings-changer input”).val(‘ . $servings . ‘).change(); });</script>’;
    }
    return $template;
    }

    add_filter( ‘wpurp_output_recipe’, ‘wpurp_output_recipe’, 10, 2 );

    Thread Starter gayathricolundalur

    (@gayathricolundalur)

    Thanks! It worked! I had to add the change function to the footer using wp_footer action; otherwise change() was not triggering the change function!

    function namespace_adjust_servings() {
    echo ‘<script>jQuery(document).ready(function() {if( jQuery(“.wpurp-recipe-servings-changer input.adjust-recipe-servings”).length ){jQuery(“.wpurp-recipe-servings-changer input.adjust-recipe-servings”).change();}});</script>’;
    }
    add_action(‘wp_footer’, ‘namespace_adjust_servings’, 100);

    I know this gets checked on all pages but could not figure out how to put the script after the adjustable_servings.js has been added to the document. Let me know if you have a better workaround!

    Thanks a bunch! Appreciate the prompt response ??

    hi, i have installed wp recipe plugin.i want to remove the text “powered by wp ulitimate recipe”.thanks for any help

    Plugin Author Brecht

    (@brechtvds)

    Hi there,

    You can disable that link on the Recipes > Settings > Recipe Template > Recipe Box page.

    Kind regards,
    Brecht

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Customize serving size’ is closed to new replies.