Test PHP

Delphi code posted
created at 24 Jul 13:09, updated at 27 Jul 19:14

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 require_once( ABSPATH . '/wp-includes/registration.php');
 3 
 4 // the configuration array
 5 $wpcas_options = array(
 6   'cas_version' => '2.0',
 7   'include_path' => '/RUTA/DEL/PHPCAS/CAS.php',
 8   'server_hostname' => 'cas.csic.es',
 9   'server_port' => '443',
10   'server_path' => '/'
11 );
12 
13 // this function gets executed 
14 // if the CAS username doesn't match a username in WordPress
15 function wpcas_nowpuser( $user_name ) {
16 
17   $datos=array("user_login"=>$user_name, // Nombre de usuario para login
18                "user_pass"=>'11111', // Contraseña
19                "user_email"=>$user_name.'@csic.es', // E-mail
20                "role"=>"contributor");
21 
22   // Insertamos los datos
23   wp_insert_user($datos);
24 
25   if( isset( $_GET['redirect_to'] )){
26 
27     wp_redirect( preg_match( '/^http/', $_GET['redirect_to'] ) ? $_GET['redirect_to'] : site_url( $_GET['redirect_to'] ));
28     die();
29                                    }
30     wp_redirect( site_url( '/wp-admin/' ));
31     die();
32   }
33 }
1.06 KB in 3 ms with coderay