这是一个快速的函数,我有躺在那里,它正是你所说的。它使用一些核心WP功能来完成工作,您必须对其进行修改以满足您的需要,可能需要再次检查事物的安全性,但它应该给您一个良好的开端。
function auto_function() {
if ( isset( $_GET[\'username\'] ) && isset( $_GET[\'email\'] ) ){
$user_name = $_GET[\'username\'];
$user_email = $_GET[\'email\'];
$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 );
$creds = array();
$creds[\'user_login\'] = $user_name;
$creds[\'user_password\'] = $random_password;
$creds[\'remember\'] = true;
$user = wp_signon( $creds, false );
$meta_key = \'some_meta_key\';
$meta =& get_user_meta($user, $meta_key, true);
$site_allowance = 3;
add_user_meta( $user->id, $meta_key, $site_allowance , TRUE );
#Redirect to help page
wp_redirect( site_url(\'/user-profile/\') ); exit;
} else {
$random_password = __(\'User already exists. Password inherited.\');
}
}
}