admin管理员组文章数量:1306306
I have this structure on my website:
And inside the game folder (the index.php
file) I'm trying to call WooCommerce and WordPress functions, to see if the user has a membership (I'm using WooCommerce Membership plugin).
With this code:
require_once('../wp-load.php' );
if (wc_memberships_is_post_content_restricted($id) && !wc_memberships_is_user_member() && !current_user_can('administrator')) {
header("Location: https:/localhost/mywebsite");
}
wc_memberships_is_post_content_restricted();
is a WooCommerce Membership function... on the localserver (wampserver) it's working, but when I try to run on my online host the functions do not work.
I also used var_dump( get_defined_functions() );
to see if the functions are properly load, and it's...
I have this structure on my website:
And inside the game folder (the index.php
file) I'm trying to call WooCommerce and WordPress functions, to see if the user has a membership (I'm using WooCommerce Membership plugin).
With this code:
require_once('../wp-load.php' );
if (wc_memberships_is_post_content_restricted($id) && !wc_memberships_is_user_member() && !current_user_can('administrator')) {
header("Location: https:/localhost/mywebsite");
}
wc_memberships_is_post_content_restricted();
is a WooCommerce Membership function... on the localserver (wampserver) it's working, but when I try to run on my online host the functions do not work.
I also used var_dump( get_defined_functions() );
to see if the functions are properly load, and it's...
- 1 "...and it's..." what? The SkyVerge team are really good about providing support so you should reach out to them to ask about functions that exist within their plugin. Third-Party plugins and WooCommerce are off-topic on WPSE. – Tony Djukic Commented Jan 20, 2021 at 15:22
1 Answer
Reset to default 0When I am using a php script in my Wordpress installation, I have special functions in the child theme, in functions.php So I have to require that as well.
Also you want to make sure that SHORTINIT is not defined as TRUE, or else you lose many Wordpress functions.
Here is how I do it.
ignore_user_abort(true);
$path = $_SERVER['DOCUMENT_ROOT'];
require( $path.'/wp-load.php' );
require_once( get_stylesheet_directory() . '/../Divi-child/functions.php' );
// now all my functions are loaded
本文标签: Load Woocommerce and Wordpress Functions Outside
版权声明:本文标题:Load Woocommerce and Wordpress Functions Outside 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741817432a2399156.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论