• Resolved artek1

    (@artek1)


    Hi

    i want to add a filter:
    wc_pay_per_post_shortcode_has_access_no_posts
    and
    wc_pay_per_post_shortcode_purchased_no_posts

    just copy – paste to functions.php

    I get:
    You have not purchased any protected posts. Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘my_theme_wc_pay_per_post_shortcode_has_access_no_posts’ not found or invalid function name in /usr/home/Talib79/domains/ids.nanecie.pl/public_html/wp-includes/class-wp-hook.php on line 307

    am I doing something wrong?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Matt Pramschufer

    (@mattpramschufer)

    Did you paste this?

    
    add_filter('wc_pay_per_post_shortcode_has_access_no_posts', 'my_theme_wc_pay_per_post_shortcode_has_access_no_posts');
    function my_theme_wc_pay_per_post_shortcode_has_access_no_posts(){
        return 'Your New Title';
    }
    

    That error message says you don’t have the function my_theme_wc_pay_per_post_shortcode_has_access_no_posts in your code. Make sure to paste entire code snippet.

    Thread Starter artek1

    (@artek1)

    when i add this filter:

    add_filter('wc_pay_per_post_shortcode_has_access_no_posts', 'my_theme_wc_pay_per_post_shortcode_has_access_no_posts');
    function my_theme_wc_pay_per_post_shortcode_has_access_no_posts(){
        return 'Your New Title';
    }

    nothing happens (the text is not overwritten and there is no error)

    in this:

    add_filter('wc_pay_per_post_shortcode_purchased_no_posts', 'my_theme_wc_pay_per_post_shortcode_has_access_no_posts');
    function my_theme_wc_pay_per_post_shortcode_purchased_no_posts(){
        return 'Your New Title';
    }

    shows error

    screen:
    scr1

    scr2

    • This reply was modified 2 years, 6 months ago by artek1.
    Plugin Author Matt Pramschufer

    (@mattpramschufer)

    1.) Your second filter is wrong, You are referencing the wrong function, it needs to be

    
    add_filter('wc_pay_per_post_shortcode_purchased_no_posts', 'my_theme_wc_pay_per_post_shortcode_has_access_no_posts');
    function my_theme_wc_pay_per_post_shortcode_has_access_no_posts(){
        return 'Your New Title';
    }
    

    For it not changing, Do you have any page caching plugins that you need to clear cache on? Or does your hosting company have server level caching you need to clear?

    Thread Starter artek1

    (@artek1)

    the documentation includes both:
    Docs link

    `
    wc_pay_per_post_args

    This filter allows you to override the WP Query arguments for the shortcodes.

    Example:
    add_filter(‘wc_pay_per_post_args’, ‘my_theme_wc_ppp_args’);
    function my_theme_wc_ppp_args($args){
    $args[‘orderby’] = ‘menu_order’;
    return $args;
    }
    wc_pay_per_post_shortcode_has_access_no_posts

    This filter allows you to override the text “You have not have access to any protected posts.” in the Has Access shortcode

    Example:
    add_filter(‘wc_pay_per_post_shortcode_has_access_no_posts’, ‘my_theme_wc_pay_per_post_shortcode_has_access_no_posts’);
    function my_theme_wc_pay_per_post_shortcode_has_access_no_posts(){
    return ‘Your New Title’;
    }
    wc_pay_per_post_shortcode_purchased_no_posts

    This filter allows you to override the text “You have not purchased any protected posts.” in the Has Access shortcode

    Example:
    add_filter(‘wc_pay_per_post_shortcode_purchased_no_posts’, ‘my_theme_wc_pay_per_post_shortcode_has_access_no_posts’);
    function my_theme_wc_pay_per_post_shortcode_purchased_no_posts(){
    return ‘Your New Title’;
    }`

    All I do is copy the two examples available for the free version

    Website is under modification. There is no cache plugin.
    Caching in hosting is disabled

    Plugin Author Matt Pramschufer

    (@mattpramschufer)

    There was a typo on the filters documentation. I just updated it.

    Unless you have a specific reason you shouldn’t be using the wc_pay_per_post_args filter.

    To change the title on the shortcode when you place it on your page you can simply add

    
    add_filter('wc_pay_per_post_shortcode_has_access_no_posts', 'my_theme_wc_pay_per_post_shortcode_has_access_no_posts');
    function my_theme_wc_pay_per_post_shortcode_has_access_no_posts(){
        return 'Your New Title';
    }
    
    

    and

    
    add_filter('wc_pay_per_post_shortcode_purchased_no_posts', 'my_theme_wc_pay_per_post_shortcode_has_access_no_posts');
    function my_theme_wc_pay_per_post_shortcode_has_access_no_posts(){
        return 'Your New Title';
    }
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘filters to override the text’ is closed to new replies.