Я хочу загрузить форму ввода в разделе своего аккаунта в Woocommerce.Но похоже, что он не read
форма или может возвращать $_GET
переменную.
Я добавил add_filter
add_filter('woocommerce_account_menu_items', 'flxz_recurring_link', 40);
function flxz_recurring_link($menu_links)
{
$menu_links = array_slice($menu_links, 0, 5, true)
+ array('flx-subscription' => 'Subscription')
+ array_slice($menu_links, 5, null, true);
return $menu_links;
}
Затем вызовите конечную точку
add_action('init', 'flxz_add_endpoint');
function flxz_add_endpoint()
{
add_rewrite_endpoint('flx-subscription', EP_PAGES);
}
И я хочу сгенерировать форму здесь
add_action('woocommerce_account_flx-subscription_endpoint', 'flxz_my_account_endpoint_content');
function flxz_my_account_endpoint_content()
{
$user_info = get_userdata(get_current_user_id());
var_dump( $_GET());
}
Когда я делаю var_dump
, он выдает эту ошибку
Fatal error: Uncaught Error: Function name must be a string in C:\xampp\htdocs\wp\wp-content\plugins\shop_recurring\index.php:42 Stack trace: #0 C:\xampp\htdocs\wp\wp-includes\class-wp-hook.php(286): flexzone_my_account_endpoint_content('') #1 C:\xampp\htdocs\wp\wp-includes\class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #2 C:\xampp\htdocs\wp\wp-includes\plugin.php(453): WP_Hook->do_action(Array) #3 C:\xampp\htdocs\wp\wp-content\plugins\woocommerce\includes\wc-template-functions.php(2842): do_action('woocommerce_acc...', '') #4 C:\xampp\htdocs\wp\wp-includes\class-wp-hook.php(286): woocommerce_account_content('') #5 C:\xampp\htdocs\wp\wp-includes\class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #6 C:\xampp\htdocs\wp\wp-includes\plugin.php(453): WP_Hook->do_action(Array) #7 C:\xampp\htdocs\wp\wp-content\plugins\woocommerce\templates\myaccount\my-account.php(34): do_action('woocommerce_acc...') #8 C:\xampp\htdocs\wp\wp-content\plugins\woocommerce\includes\wc-core-functions.php(208): include('C:\\xampp\\ht in C:\xampp\htdocs\wp\wp-content\plugins\shop_recurring\index.php on line 42
Спасибо:)
<?php
/*
Plugin Name: Woocommerce Recurring
Plugin URI: https://localhost
Description: Recurring Plug-in for Wordpress
Version: 1.0
Author: Daan
Author URI: https://localhost
License: MIT
*/
// Load Subscription link in Woocommerce
add_filter('woocommerce_account_menu_items', 'flxz_recurring_link', 40);
function flxz_recurring_link($menu_links)
{
$menu_links = array_slice($menu_links, 0, 5, true)
+ array('flx-subscription' => 'Subscription')
+ array_slice($menu_links, 5, null, true);
return $menu_links;
}
add_action('init', 'flxz_add_endpoint');
function flxz_add_endpoint()
{
add_rewrite_endpoint('flx-subscription', EP_PAGES);
}
add_action('woocommerce_account_flx-subscription_endpoint', 'flxz_my_account_endpoint_content');
function flxz_my_account_endpoint_content()
{
$user_info = get_userdata(get_current_user_id());
// var_dump( $_GET());
print '
<form action="" method="post"></form>
<input type="text" name="Blablabla" id="Blablabla">
</form>
';
}