Is it possible when a member logs in for them

Hi,

Is it possible when a member logs in for them to be redirected to their own web page on our site which can only be viewed by them and admin?

Thanks...

  • Rupok

    Hey carl

    Hope you are having a wonderful day.

    Yes, it can be done but I could tell you more about it if I could get some additional information about your site. For example, the following code redirects admins to the dashboard and other users to the homepage:

    function my_login_redirect( $redirect_to, $request, $user ) {
    	//is there a user to check?
    	global $user;
    	if ( isset( $user->roles ) && is_array( $user->roles ) ) {
    		//check for admins
    		if ( in_array( 'administrator', $user->roles ) ) {
    			// redirect them to the default place
    			return $redirect_to;
    		} else {
    			return home_url();
    		}
    	} else {
    		return $redirect_to;
    	}
    }
    
    add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

    Now, about the second query "which can only be viewed by them and admin", I think there is no easy way for restricting a web page to only a specific user. However, you can create a custom page template where you can check which user is logged in and then serve content according that user ID/level.

    Can you please describe a little more about what type of page your users are having? Are you using any membership plugin to restrict content? Can you give me any link where I can check? Are you having a Single site or Multisite?

    I'm looking forward to hear from you and solve your query as soon as possible.

    Have a nice day. Cheers!
    Rupok

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.