Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

sidebar login redirect WordPress

hi,

I'm using the sidebar login plugin and need some help to redirect the user after login to custom post type content that has the same name of the user.

the plug-in has this field on admin:

Login redirect: "http://... (Url to redirect the user to after login. Leave blank to use the current page).

but it seems to work only with static urls, like:

http://127.0.0.1:8888/client/custompostype/

but not:

http://127.0.0.1:8888/client/custompostype/username

thanks a lot

Answers (2)

2011-09-13

Kannan C answers:

Can you attach the plugin file? or let me know where i can find it


Manuel comments:

http://wordpress.org/extend/plugins/sidebar-login/


Kannan C comments:

Find this function widget_wp_sidebarlogin_check() in sidebar-login.php around line no 224
replace this two lines global $login_errors;

// Get redirect URL
$redirect_to = trim(stripslashes(get_option('sidebarlogin_login_redirect')));

to

global $login_errors, $current_user;
get_currentuserinfo();
$username = $current_user->user_login;
// Get redirect URL
$redirect_to = get_bloginfo('url')."/client/custompostype/"$username.;

If you custom url (http://127.0.0.1:8888/client/custompostype/username) correctly resolve this should work correctly.


Kannan C comments:

sorry i missed the concatenation
here is correct one

global $login_errors, $current_user;
get_currentuserinfo();
$username = $current_user->user_login;
// Get redirect URL
$redirect_to = get_bloginfo('url')."/client/custompostype/".$username;


Manuel comments:

hi kannan,

thanks for you fast answer.
unfortunately with this fix, the logins works fine, but not the redirect to user's custom page...


Kannan C comments:

(http://127.0.0.1:8888/client/custompostype/username) is this url loading when you load this directly in to the browser?


Manuel comments:

yes, it works


Kannan C comments:

Oops! i didn't noticed that user login function is doing after that line.
Please find the line

// Login
$user = wp_signon('', $secure_cookie);

Paste this two line after the above line

$username = $user->user_login;
$redirect_to = get_bloginfo('url')."/client/custompostype/".$username;


Manuel comments:

...still no redirecting :(


Kannan C comments:

its working for me.
can you attach your edited sidebar-login.php file?


Manuel comments:

(attached)


Kannan C comments:

your edited file too working for me. Try deleting the previous edits. You just need to add this two lines of code (from the original code)

$username = $user->user_login;
$redirect_to = get_bloginfo('url')."/client/showreel/".$username;

after this

$user = wp_signon('', $secure_cookie);

Do you see any errors after login? otherwise to where it is redirecting currently?


Manuel comments:

so, ...made some test without results, there is no redirect.
( I just re-upload the file, you can see on line 120 the problem and the output I get on my localhost testings) thanks a lot.

manuel


Kannan C comments:

you placed it in wrong function.
i posted the corrected version here http://pastebin.com/8eHJxJwY

2011-09-14

Hardeep Singh answers:


I had a similar problem with one of the plugins and urlencode() resolved the issue.

$redirect_to = trim(stripslashes(get....

change to

$redirect_to = urlencode(trim(stripslashes(get....

Don't forget to close the bracket.

Let me know, if that helped.