我使用插件wp-members for wordpress,我需要修改登錄表單,並且在我將數組輸入到函數後,我得到這個錯誤「致命錯誤:調用上的空成員函數get_text()」「致命的錯誤:調用一個成員函數get_text()null」在wordpress
這是我的functions.php
add_filter('wpmem_login_form', 'my_login_form_filter');
function my_login_form_filter($form, $action = 'login')
{
/**
* The login form is brought in with $form
* You can append to it or filter it
*
* $action specifies the form being constructed. It
* can be: login|pwdreset|pwdchange
*/
$form = array(
array(
'name' => $wpmem->get_text("login_username"),
'type' => 'text',
'tag' => 'log',
'class' => 'username',
'div' => 'div_text',
),
array(
'name' => $wpmem->get_text("login_password"),
'type' => 'password',
'tag' => 'pwd',
'class' => 'password',
'div' => 'div_text',
),
array(
'name' => $wpmem->get_text("login_number"),
'type' => 'text',
'tag' => 'log',
'class' => 'username',
'div' => 'div_text',)
);
return $form;
}
碼這是插件的代碼有問題
節if (! function_exists('wpmem_inc_login')):
/**
* Login Dialog.
*
* Loads the login form for user login.
*
* @since 1.8
*
* @global object $wpmem The WP_Members object.
* @global string $wpmem_regchk The WP-Members message container.
* @global object $post The WordPress Post object.
*
* @param string $page
* @param string $redirect_to
* @return string $str The generated html for the login form.
*/
function wpmem_inc_login($page = "page", $redirect_to = null, $show = 'show') {
global $wpmem, $wpmem_regchk, $post;
$str = '';
if ($page == "page") {
if ($wpmem_regchk != "success") {
$dialogs = get_option('wpmembers_dialogs');
// This shown above blocked content.
$msg = $wpmem->get_text('restricted_msg');
$msg = ($dialogs['restricted_msg'] == $msg) ? $msg : __(stripslashes($dialogs['restricted_msg']), 'wp-members');
$str = "<p>$msg</p>";
/**
* Filter the post restricted message.
*
* @since 2.7.3
*
* @param string $str The post restricted message.
*/
$str = apply_filters('wpmem_restricted_msg', $str);
}
}
// Create the default inputs.
$default_inputs = array(
array(
'name' => $wpmem->get_text('login_username'),
'type' => 'text',
'tag' => 'log',
'class' => 'username',
'div' => 'div_text',
),
array(
'name' => $wpmem->get_text('login_password'),
'type' => 'password',
'tag' => 'pwd',
'class' => 'password',
'div' => 'div_text',
),
);
/**
* Filter the array of login form fields.
*
* @since 2.9.0
*
* @param array $default_inputs An array matching the elements used by default.
*/
$default_inputs = apply_filters('wpmem_inc_login_inputs', $default_inputs);
$defaults = array(
'heading' => $wpmem->get_text('login_heading'),
'action' => 'login',
'button_text' => $wpmem->get_text('login_button'),
'inputs' => $default_inputs,
'redirect_to' => $redirect_to,
);
/**
* Filter the arguments to override login form defaults.
*
* @since 2.9.0
*
* @param array $args An array of arguments to use. Default null.
*/
$args = apply_filters('wpmem_inc_login_args', '');
$arr = wp_parse_args($args, $defaults);
$str = ($show == 'show') ? $str . wpmem_login_form($page, $arr) : $str;
return $str;
}
endif;
這意味着您正在調用的函數沒有從您使用的表單獲取值。嘗試尋找表單輸入名稱 –