Authenticating using a seperate rest server
-
Hi all
i am using forminator to create a form i can use to login. i want to use authentication
add_action(“forminator_form_submit_response”, “save_fielder_details”, 10, 2);
add_filter(‘forminator_custom_form_after_send_email’, ‘custom_form_submit’, 11, 2);
add_filter( ‘wp_authenticate’, ‘wp_authenticate_custom’, 13, 2 );
add_filter( ‘authenticate’, ‘custom_authenticate_username_password’, 9, 3 );
add_action( “template_redirect”, “my_function”,20 );function save_fielder_details($response, $form_id) {
error_log(print_r($response, true)); if ($form_id === "58") { login_To_best($form_id); }return $response;
}function wp_authenticate_custom ( $username,$password ) {
$username = sanitize_user( $username );
$password = trim( $password );$data = array(
’email’ => sanitize_user($entries->meta_data [’email-1′][‘value’]),
‘password’ =>trim($entries->meta_data [‘password-1’][‘value’])
);$postvars = http_build_query($data);
$url = ‘http://NottherealUrl.com’;$ch = curl_init($url);
// set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
// $response = curl_exec($ch);
$user = apply_filters( ‘authenticate’, new WP_User(), $username, $password );$current_user = $user;
// echo print_r($current_user);
/* $property = $wpdb->prefix . ‘capabilities’;
$caps = $userinfo->$property;
foreach ( $caps as $role ) {
if ( ‘special_authenticator’ == $role ) {
wpExternalLoginProcess( $username, $_POST[‘pwd’] );
}
} */if ( $user != null ) {
wp_safe_redirect(“/index.php/sample-page/”);
} else {
wp_safe_redirect(“/index.php/login/”);
}
echo “is terry here”.”
\n”;}
function my_function(){
global $current_user;
$current_user = get_current_user();
echo print_r($current_user);
}function custom_authenticate_username_password( $user, $username, $password){
$user->ID=5;
echo print_r($user);
return $user;}
the data does not appear to be stored
The topic ‘Authenticating using a seperate rest server’ is closed to new replies.