AI Verified

Name

Fluen Forms Login

Language

PHP

Rating

Voted: 0 by 0 user(s)

Codevault

Blushopi

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.4

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

15/01/2024

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Potential vulnerability found : Insecure E-mail
Found on line : -1
Code : mail(|| !$password)
Vulnerable line : 26
Code : $password = \FluentForm\Framework\Helpers\ArrayHelper::get($data, 'password')); // your form should have password field

Potential vulnerability found : Insecure E-mail
Found on line : 33
Code : mail($email)
Vulnerable line : 25
Code : $email = \FluentForm\Framework\Helpers\ArrayHelper::get($data, 'email')); // your form should have email field

Found 2 vulnerabilities

Fluen Forms Login

 
                    
1add_action('fluentform_before_insert_submission', function ($insertData, $data, $form) {
2 
3 if($form->id != 5) { // 23 is your form id. Change the 23 with your own login for ID
4 return;
5 }
6 
7 $redirectUrl = home_url(); // You can change the redirect url after successful login
8 
9 // if you have a field as refer_url as hidden field and value is: {http_referer} then
10 // We can use that as a redirect URL. We will redirect if it's the same domain
11 // If you want to redirect to a fixed URL then remove the next 3 lines
12 if(!empty($data['refer_url']) && strpos($data['refer_url'], site_url()) !== false) {
13 $redirectUrl = $data['refer_url'];
14 }
15 
16 if (get_current_user_id()) { // user already registered
17 wp_send_json_success([
18 'result' => [
19 'redirectUrl' => $redirectUrl,
20 'message' => 'Your are already logged in. Redirecting now...'
21 ]
22 ]);
23 }
24 
25 $email = \FluentForm\Framework\Helpers\ArrayHelper::get($data, 'email'); // your form should have email field
26 $password = \FluentForm\Framework\Helpers\ArrayHelper::get($data, 'password'); // your form should have password field
27 
28 if(!$email || !$password) {
29 wp_send_json_error([
30 'errors' => ['Please provide email and password']
31 ], 423);
32 }
33 
34 $user = get_user_by_email($email);
35 if($user && wp_check_password($password, $user->user_pass, $user->ID)) {
36 wp_clear_auth_cookie();
37 wp_set_current_user($user->ID);
38 wp_set_auth_cookie($user->ID);
39 /* user is not logged in.
40 * If you use wp_send_json_success the the submission will not be recorded
41 * If you remove the wp_send_json_success then it will record the data in fluentform
42 * in that case you should redirect the user on form submission settings
43 */
44 wp_send_json_success([
45 'result' => [
46 'redirectUrl' => $redirectUrl,
47 'message' => 'Your are logged in, Please wait while you are redirecting'
48 ]
49 ]);
50 } else {
51 // password or user don't match
52 wp_send_json_error([
53 'errors' => ['Email / password is not correct']
54 ], 423);
55 }
56}, 10, 3);

0

Related Snippets

Please see some snippets below related to this snippet..

General

AI Verified

0

Auto-add alt text based on file name when inserting an image.

Added: 4 months ago

Last Updated: 4 months ago

Auto-add alt text based on file name when inserting an image.

General

Unverified

0

CSS Tour Menu

Added: 9 months ago

Last Updated: 1 week ago

General

AI Verified

0

Gutenberg - zakáže welcome okno

Added: 9 months ago

Last Updated: 9 months ago

Zakáže uvítací okno Gutenbergu

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

General

AI Verified

0

Convertir imagenes ha formato Webp

Added: 7 months ago

Last Updated: 7 months ago

General

AI Verified

0

Fluen Forms Login

Added: 7 months ago

Last Updated: 7 months ago

General

AI Verified

0

Cerrar sesion - cliente

Added: 7 months ago

Last Updated: 7 months ago