我在WordPress中编写了登录页面的HTML代码。我正在使用phpmyadmin(wamp)。如何将此表单与MySQL连接?我必须写什么PHP代码?
此外,如果我使用插件,其中将存储表格数据?请指导我。
答案 0 :(得分:1)
以下是登录的documentation,这里是注册用户的documentation
登录示例代码
function custom_login() {
$creds = array();
$creds['user_login'] = 'example';
$creds['user_password'] = 'plaintextpw';
$creds['remember'] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) )
echo $user->get_error_message();
}
// run it before the headers and cookies are sent
add_action( 'after_setup_theme', 'custom_login' );
用户注册示例
$user_id = username_exists( $user_name );
if ( !$user_id and email_exists($user_email) == false ) {
$random_password = wp_generate_password( $length=12,
$include_standard_special_chars=false );
$user_id = wp_create_user( $user_name, $random_password, $user_email );
} else {
$random_password = __('User already exists. Password inherited.');
}