Arrow

Redirect by User Name | Peter's Login Redirect | Forum

Back to the login redirect plugin page

Please consider registering
guest

Log In

Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

   

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Redirect by User Name
June 5, 2012
12:38 pm
DB
Guest

Hi,
Looking at this plugin as a potential solution for a custom landing page for each user. Will I have the ability to assign by user name a custom page to be redirected to? I have hundreds of users and would like to assign each of them a custom landing page. Please let me know if this is possible with this plugin. If so, is there a lot of coding to accomplish, or do I set up a rule for each user in the "settings > login/logout redirect" section? Thanks for any clarification you can provide!

June 5, 2012
1:04 pm
Peter
Admin
Forum Posts: 841
Offline

Yes, you can put [variable]username[/variable] as part of your redirect URL, and it would get dynamically replaced by the username.

You could also have a generic page with dynamic logic that uses the username or user ID without having to read a URL string.

June 7, 2012
4:58 am
Megan Walker
Guest

Sorry to jump in but this is relevant to what I am trying to do. I have the [variable]username[/variable] set up for my redirect right now for a client role I created. Is it possible to use other variables? For example, I created a new field on a user record called company_name. I tried adding that as a variable but it didn't seem to work. Is it possible I was just doing this wrong, or could you use another variable in the redirect rule?

June 7, 2012
6:56 am
Peter
Admin
Forum Posts: 841
Offline

Hi,

Out of the box variables are:
username, homeurl, siteurl, and postid-23

You can add your own variables by following the documentation under "Custom variable parameters" on this page:
http://wordpress.org/extend/pl.....her_notes/

June 7, 2012
9:48 am
Megan Walker
Guest

Hi Peter, let me know if you want me to repost and start a new thread for this. I viewed the page about Custom Variable Parameters on that page. From that page I see the available filter "rul_replace_variable" for adding your own custom variable names. I am just not sure how to follow that logic for a variable name of 'company' that is an alpha string. Also, where would I put it?

In the wplogin_redirect.php file, I found the following code. Do I change $variable to $company? Sorry if this is obvious, I am a work in progress. Frown

*/
function rul_get_variable( $variable, $user )
{
$variable_value = apply_filters( 'rul_replace_variable', false, $variable, $user );
if( !$variable_value )
{
// Return the permalink of the post ID
if( 0 === strpos( $variable, 'postid-' ) )
{
$post_id = str_replace( 'postid-', '', $variable );
$permalink = get_permalink( $post_id );
if( $permalink )
{
$variable_value = $permalink;
}
}

June 8, 2012
9:02 am
Peter
Admin
Forum Posts: 841
Offline

Hi Megan,

The example at the bottom of the link I sent you is closer to what you need. You would place that in a separate plugin file or in your theme's functions.php file. In short, your custom function would check for the custom variable name, and if it matches, it would use the $user object to look up the relevant company.

June 12, 2012
11:36 am
Megan Walker
Guest

Hi Peter,

Thanks for the guideance. I have been tryign to figure this out but still not quite sure how to bring in my custom variable for the redirect. My variable is a field called template. I can display this variable on a page so I know it exists in the database. Just not sure how to use it for the redirect. Using the code at the bottom of this comment, the redirect effect takes the user to a string like this:

http://domain.com/clients/?_lo.....4227cbcbe3

instead of something like this:

http://domain.com/clients/template

I wasn't sure what the 'rul_replace_variable', 'customRULVariableMonth', 10, 3 would need to be. What is that doing? Should customRULVariableMonth be changed to something else? Thanks again for your help, sorry I am just not quite getting the whole picture!

/* BEGIN Peters Login Redirect Custom Variable */

function customRULVariableMonth( $custom_redirect_to, $variable, $user )
{
if( 'template' == $variable )
{
return wp_get_current_user($current_user->template);
}
else
{
return $custom_redirect_to;
}
}

add_filter( 'rul_replace_variable', 'customRULVariableMonth', 10, 3 );

/* END Peters Login Redirect Custom Variable */

June 12, 2012
6:14 pm
Peter
Admin
Forum Posts: 841
Offline

Hi Megan, your framework looks correct. The add_filter line is there to "hook" your function into the "rul_replace_variable" event in my plugin, so that my plugin executes your function when looking for custom URL variables. Looks like you just need correct code to replace return wp_get_current_user($current_user->template); (which appears to be attempting to fetch a user, although you have the user object available with $user).

I cannot tell you what the exact code would be for your install without getting onto your system (which I'd have to do as billable time). However, you can likely Google for something like "get custom user fields" to find code that will grab a custom user field given a user object.

June 24, 2012
9:39 am
Mike
Guest

Hi I've just installed this plugin and set it to create a [variable]username[/variable] for each new member. The problem I've having is that they get redirected to the correct Url but that page doesn't get created so they get a 404 message. Is something wrong with the plugin or was this designed so that I have to create the page manually?

E.g. if someone called mike signs up he will be redirected to mysite.com/mike upon login but the page doesn't exist.

Any help would be greatly appreciated.

June 25, 2012
7:26 am
Peter
Admin
Forum Posts: 841
Offline
10

Hi,

This plugin is designed to handle the redirect only.

However, you could create just one page and have it dynamic based on a GET parameter that specifies the username or user ID.

July 19, 2012
2:28 pm
Matt Miller
Guest
11

Hi Peter ...

I'm a pretty novice WordPress user but I'm getting by. I've installed your login redirect plugin and am having trouble getting it to work. I've selected specific users for login redirect and have entered URLs. However, whenever I log in, those users aren't redirected.

Screenshot of users and URLs at: http://riseaboveindiana.com/wp.....direct.png

Website is: http://www.riseaboveindiana.com.

Sorry if I'm missing something very obvious (which I'm sure is probably the case). Thanks in advance for your help!

Matt

July 19, 2012
9:46 pm
Peter
Admin
Forum Posts: 841
Offline
12

Hi Matt,

Your screenshot indicates that those users should be redirected. Do you have any other plugins that could be conflicting?

August 15, 2012
6:31 am
Mike B
Guest
13

I have a different problem than some of the rest.
I installed the plugin and when i add a specific user, it SAYS it adds them, but they do not show up like the previous poster (matt millers) picture.
http://newsite.safetyregulatio.....roblem.PNG

the other weird thing is it will ONLY redirect the last username i enter in.
So if i enter in two users the last person i enter is the ONLY one that will redirect....
what am i missing?

August 15, 2012
7:12 am
mike b
Guest
14

i followed this:
http://www.theblog.ca/peter-fo.....abase-woes

and i was manually able to enter additional users, does anyone have a fix to this so i do not have to go into phpmyadmin every time i want to add a user?
plus my users now don't show up in clean lists under "login/logout redirects

September 1, 2012
6:10 pm
dl
Guest
15

I believe I may be asking a similar question as many others but am not sure. I am a novice so forgive me if am being repetitive here. I love this plugin. I can successfully redirect users to different pages after login. I am just very confused on how to hide or replace the url of the redirect address. So when a user gets re-directed to their special page: Example - http://www.mysite.com/clients/client25 How can I make that url appear something like : Example - http://www.mysite.com/clients/replaced or hidden? Is using [variable]username[/variable] the solution? If it is I cannot get it to work. Any advice, help, or links to proper tutorials would be awesome. Thanks. And thanks for creating this great plugin.

September 2, 2012
8:54 am
Peter
Admin
Forum Posts: 841
Offline
16

That hasn't been asked before :) That isn't a feature of this plugin, though. You'd have to look into some sort of URL translator or simply write the functionality that you're looking for at a generic URL. For example, if "client25" is representative of the user's ID, you can handle the lookup of their ID completely in PHP, and don't have to rely on the URL to supply that information.

October 3, 2012
9:11 am
Polly
Guest
17

Hi Peter and everybody else.
Congratulations for the great plugin, Peter!
I understand the goal of it and I'm very grateful for having it today.
My problem is that I'd like to add [variable]username[/variable] to the URL but no idea how to do it.
Please excuse my ignorance!
I read everything on the link you provided few times but it seams I need some php knowledge which I don't have at all.
I'd like to redirect my users to their personal pages and I hope you will jump down to my low level to say how...Sorry!
Have a great time!
Best,
Polly

October 3, 2012
9:18 am
Polly
Guest
18

Polly said:

Hi Peter and everybody else.
Congratulations for the great plugin, Peter!
I understand the goal of it and I'm very grateful for having it today.
My problem is that I'd like to add [variable]username[/variable] to the URL but no idea how to do it.
Please excuse my ignorance!
I read everything on the link you provided few times but it seams I need some php knowledge which I don't have at all.
I'd like to redirect my users to their personal pages and I hope you will jump down to my low level to say how...Sorry!
Have a great time!
Best,
Polly

Peter!
Your plugin is GREAT!
I didn't put anything to any URL. I've created a page called "user's name", add a user with that name and log with it immediately in his page! Unbelievable! Works a a charm! Please ignore my previous message.
Bless you, Peter!
Polly

October 10, 2012
9:07 am
jafet
Guest
19

Hello,

I can't get the plugin to redirect to anywhere.

How do I troubleshoot? I followed all the instructions, and the plugin loads fine.

Kindest regards,

October 10, 2012
9:17 am
Peter
Admin
Forum Posts: 841
Offline
20

Usually if redirection isn't working, there is a conflict with another plugin that is bypassing the WordPress redirect hooks: usual culprits include custom login forms and BuddyPress. That, or the redirect rule isn't matching.