how to hide wordpress backend from users
Quote from linuxlife on February 18, 2022, 1:14 pmhello all! first time here…
would like to ask,is there any way to totally hide the wordpress backend panel from my users?
i need the users to do whatever they do inside the asgaros forum,not in wp…….any help appreciated!
hello all! first time here…
would like to ask,is there any way to totally hide the wordpress backend panel from my users?
i need the users to do whatever they do inside the asgaros forum,not in wp…….
any help appreciated!
Quote from Jim on February 18, 2022, 3:42 pm@linuxlife, The reason the users are sent to the backend, of course, is to see and edit their profile. Currently there is no way within the forum plugin to do that on the frontend (although I hope @asgaros will be able to incorporate that).
If you don’t mind your users not having access to the backend profile, you can redirect them on login. How you do that depends on your login method. There are lots of plugins that can do it, but here’s some code for functions.php that can do it. It assumes that you put login links on various pages of your site. If the user is logged in, it displays their name and logout and profile edit links (I have front-end profile editing incorporated into my version of Asgaros). If not, it presents a login link with a redirect to that page so they come back there after login. You would put the shortcode wherever you want these links.
/********************************************************/ /* User Info for logged-in and logged-out users */ /* Put shortcode in a text widget in sidebar */ /* or in a floated div. */ /* Login redirects to current page */ /********************************************************/ function af_login_module() { if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); $displayname = $current_user->display_name; $af = new AsgarosForum(); $afp = new AsgarosForumProfile($af); $editLink = $afp->get_editprofile_link($current_user); $text = 'Logged in as <b>' . $displayname . '</b><br \>'; $text .= '<a href="' . esc_url($editLink) . '">Edit or Delete Profile</a>'; $text .= '<br \><a href="' . wp_logout_url() . '">Log Out</a>'; } else { global $wp; $current_url = home_url( add_query_arg( array(), $wp->request ) ); $URL = esc_url( wp_login_url( $current_url ) ); $text = '<a href="' . $URL . '">Login</a><br \><a href="' . wp_registration_url() . ' ">Register</a>'; } return $text; } add_shortcode( 'af_login_shortcode', 'af_login_module' );Without front-end editing, you don’t need the $af, $afp, or $editlink parts.
When a user registers and goes through a confirmation process, the redirect won’t work that first time, and they will still go to the backend. To fix that:
// The redirect in the shortcode module doesn't work for new users // who login after creating password. This keeps them out of wp-admin/profile.php function fp_login_redirect( $redirect_to, $request, $user ) { if ($request == '') return home_url(); else return $request; } add_filter( 'login_redirect', 'fp_login_redirect', 10, 3 );This code could perhaps be improved, but it works for me.
@linuxlife, The reason the users are sent to the backend, of course, is to see and edit their profile. Currently there is no way within the forum plugin to do that on the frontend (although I hope @asgaros will be able to incorporate that).
If you don’t mind your users not having access to the backend profile, you can redirect them on login. How you do that depends on your login method. There are lots of plugins that can do it, but here’s some code for functions.php that can do it. It assumes that you put login links on various pages of your site. If the user is logged in, it displays their name and logout and profile edit links (I have front-end profile editing incorporated into my version of Asgaros). If not, it presents a login link with a redirect to that page so they come back there after login. You would put the shortcode wherever you want these links.
/********************************************************/ /* User Info for logged-in and logged-out users */ /* Put shortcode in a text widget in sidebar */ /* or in a floated div. */ /* Login redirects to current page */ /********************************************************/ function af_login_module() { if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); $displayname = $current_user->display_name; $af = new AsgarosForum(); $afp = new AsgarosForumProfile($af); $editLink = $afp->get_editprofile_link($current_user); $text = 'Logged in as <b>' . $displayname . '</b><br \>'; $text .= '<a href="' . esc_url($editLink) . '">Edit or Delete Profile</a>'; $text .= '<br \><a href="' . wp_logout_url() . '">Log Out</a>'; } else { global $wp; $current_url = home_url( add_query_arg( array(), $wp->request ) ); $URL = esc_url( wp_login_url( $current_url ) ); $text = '<a href="' . $URL . '">Login</a><br \><a href="' . wp_registration_url() . ' ">Register</a>'; } return $text; } add_shortcode( 'af_login_shortcode', 'af_login_module' );
Without front-end editing, you don’t need the $af, $afp, or $editlink parts.
When a user registers and goes through a confirmation process, the redirect won’t work that first time, and they will still go to the backend. To fix that:
// The redirect in the shortcode module doesn't work for new users // who login after creating password. This keeps them out of wp-admin/profile.php function fp_login_redirect( $redirect_to, $request, $user ) { if ($request == '') return home_url(); else return $request; } add_filter( 'login_redirect', 'fp_login_redirect', 10, 3 );
This code could perhaps be improved, but it works for me.
Quote from EBONYNSWEET on February 19, 2022, 11:10 am@linuxlife You need to use a redirection plugin to direct your users away from the WordPress dashboard. You also need to redirect users away from your default WordPress login and register pages, too, if you prefer to use custom forms. All Wordpress links will have this placed somewhere: /wp-
To match custom forms with the theme of my website, I use the Ultimate Member plugin. Use Ultimate member to create custom login, register, and profile pages. You will need to set up those first, and then you can use the redirection plugin to redirect your users to those custom pages.
Afterward, your users won’t know they are on a WordPress website.
@linuxlife You need to use a redirection plugin to direct your users away from the WordPress dashboard. You also need to redirect users away from your default WordPress login and register pages, too, if you prefer to use custom forms. All Wordpress links will have this placed somewhere: /wp-
To match custom forms with the theme of my website, I use the Ultimate Member plugin. Use Ultimate member to create custom login, register, and profile pages. You will need to set up those first, and then you can use the redirection plugin to redirect your users to those custom pages.
Afterward, your users won’t know they are on a WordPress website.