Hi @oneminduniv
Please use this filter wt_user_allowed_posts along with this version of the plugin to alter the post array and set your desired post object if the array is empty.
Thank you for your reply.
RE: Please use this filter wt_user_allowed_posts
I do not see additional settings in the new plugin; Would I add the wt_user_allowed_posts to the functions.php file or may be create the filter as a plugin?
I’m not sure how to write the filter; what I want to do is direct members that need to upgrade to access content to a custom upgrade page vs a 404 error. The upgrade page will be the same for all memberships.
Thank again!
Hi @oneminduniv
You may use the snippet in functions.php like
add_filters('wt_user_allowed_posts' , 'my_custom_page');
function my_custom_page($posts){
return array(
20 => // change your custom page id here
get_post(20)
);
}
Please let us know if any issues.
Getting PHP errors with the snippet above.
Parse error: syntax error, unexpected ‘&’ On line 13
When I remove the extra “&” here > add_filters('wt_user_allowed_posts' , 'my_custom_page');
I get > (T_STRING), expecting ‘(‘ On line 14`
Never mind on the above; I took your code from the WP email that added ' in place of ‘
But now that I have the code as you posted above, I’m getting new errors
-
This reply was modified 7 years, 11 months ago by
oneminduniv.
-
This reply was modified 7 years, 11 months ago by
oneminduniv.
-
This reply was modified 7 years, 11 months ago by
oneminduniv.
New errors
Fatal error: Uncaught Error: Call to undefined function add_filters() in /home/www/xxxxxx.com/wp-content/plugins/member-upgrade-notice/member-upgrade-notice.php:12 Stack trace: #0 /home/www/xxxxxx.com/wp-admin/includes/plugin.php(1897): include() #1 /home/www/xxxxxx.com/wp-admin/plugins.php(172): plugin_sandbox_scrape(‘member-upgrade-…’) #2 {main} thrown in /home/www/xxxxxx.com/wp-content/plugins/member-upgrade-notice/member-upgrade-notice.php on line 12
Hi @oneminduniv
That error is coming from the plugin “member-upgrade-notice”. Please check by disabling that to confirm.
RE: That error is coming from the plugin “member-upgrade-notice”
Yes, I created a plugin (vs adding code to functions.php) using your code from above, I just named the plugin member-upgrade-notice;
add_filters('wt_user_allowed_posts' , 'my_custom_page');
function my_custom_page($posts){
return array(
20 => // change your custom page id here
get_post(20)
);
}
And when I tried to activate the plugin I got the error notice above.
I’m not very good with PHP, but I think the function > my_custom_page should be declared before the filter > add_filters(‘wt_user_allowed_posts’ , ‘my_custom_page’);
Thank you
Hi @oneminduniv
You can raise a support ticket here in our support tab. So we can check this in your site.
Hi @oneminduniv
Please check with the latest version of the plugin. There is option to set default access denied page.