Thursday 15 May 2014

how to keep the user login for all pages in wordpress custom login function? -


I am using custom login function in fuction.php for the client area. But the problem is that the user only logs for one page if the user goes to another page. He has to enter again and he has to do this.

How can I have user login for all pages instead of one?

Also, plz my review login function. If i am right

PLZ Support.

  function login () {global $ wpdb; If (isset ($ _ POST ['loggingg']) and! Empty ($ _ POST ['loggingg'])) {$ email = $ wpdb- & gt; Escape ($ _REQUEST ['email']); $ Pass = $ wpdb- & gt; Escape ($ _REQUEST ['pass']); $ Sql ​​= $ wpdb- & gt; Get_results ("SELECT * FROM wp_users where user_email = '$ email'"); $ Points = $ wpdb- & gt; Num_rows; Forex Currency ($ sql $ fsql) {$ password = $ fsql- & gt; User_pass; $ User_id = $ fsql- & gt; Id; $ Username = $ fsql- & gt; Fname; $ Mem = $ fsql- & gt; Remember; } If ($ password) {$ login_data = array (); $ Login_data [] = $ username; $ Login_data [] = $ password; $ Login_data [] = $ mem = true; $ Wpdb- & gt; Query ("UPDATE wp_users SET useronline = '1' where id = '$ user_id'"); $ User_verify = wp_signon ($ login_data, FALSE); Wp_set_auth_cookie ($ user_verify, 0, 0); Wp_set_current_user ($ user_id, $ username); Do_action ('wp_set_current_user'); } Else {echo "username" password is incorrect. If you have forgotten the ur password & lt; a href = '#' & gt; here & lt; / a & gt; "; }}}    

You can use the wp signon function You can see:

As you can see here:

  & lt ;? Php wp_signon ($ credentials, $ secure_cookie)? & Gt;   

This happens and the array ($ credentials) and a boolean (which is optional).

Here you can see a sample code which is used:

  $ creds = array (); $ Creds ['user_login'] = 'username'; $ Creds ['user_password'] = 'password'; $ Creds ['remember'] = true; $ User = wp_signon ($ creds, false); If (is_wp_error ($ user)) $ user- & gt; Get_error_message ();   

This function is a core WP function, which means that when it is used, it does all this for WordPress to make it work for it should do.

Next, you need to use.

In your case I have noticed that you have used it: which is taking these parameters:

    

$ user_id is an integer and $ memorize is a bullion (true / false).

In the $ user_id you tried to enter a variable which is not an integer, it is $ user_verify-> Replace id with and it should work.

No comments:

Post a Comment