Home>
I want to redirect with WordPress user_role_editor.
I'd like to create a new permission and change the page after login, but it doesn't work.
I added the following code to function.php, but it goes to the officer with all privileges.
This is a new permission created by 'Customer'.
// Redirect by privilege at login
function redirect_login_page () {
if (current_user_can ('Customer')) {
$url = home_url ('/ customer', 'http');
wp_safe_redirect ($url);
exit ();
} else {
$url = home_url ('/ officer', 'http');
wp_safe_redirect ($url);
exit ();
}
}
add_action ('wp_login', 'redirect_login_page');
I considered the influence of other plug-ins, but I think that the function is alive as long as I go to the officer.
-
Answer # 1
-
Answer # 2
Sorry. Eventually I created a new permission and solved it with another plug-in.
Related articles
- php - if you change the site address on wordpress, it will redirect to other domains without permission
- php - does disappear when i post to wordpress with xmlrpc?
- php - i started wordpress, but i can't log in
- php - i want to create a member site in wordpress without using a plugin
- php - cannot output wordpress acf
- php - the wordpress theme xeory extension top page service article does not show the catchy image
- php - anchor link from the top page link to another page on the same site in wordpress
- php - i want to hide the editor on the wordpress custom post page
- php - i want to search wordpress in real time
- php - i wrote a code to hide posts in a wordpress subloop but it doesn't work
- php - how to set google recaptcha v3 in wordpress (no plugin used)
- php - how to require files in a theme with wp tags in wordpress
- php - [wordpress] i want to customize the title of the web page
- php - wordpress: i want to be able to clear&save the item value as a blank on the original setting page added to the managem
- php - [wordpress] i want to display the ip address in the comment field
- wordpress debuglog no longer prints php errors
- php - when i update wordpress, i get an error please tell me the cause of the syntax error
- php - an error message that cannot be read by wordpress is displayed
- php - i want to set it to any parameter when creating a page with add_menu_page of wordpress
- wordpress i want to redirect to another wordpress page on the same server
Related questions
- php : How to pass the value of a variable to another file
- php - how to display the full text of wordpress rss feed without images
- is it possible to put php code in {} in an if statement?
- php - wordpress downgrade fails with fatal error and site not displayed
- php - i want to assign the value of a custom field template to the permission branch
- php - about wordpress and javascript jquery
- php - i want the custom taxonomy slug to be the same as the custom post type
- php - how to exclude apostrophes with $wpdb-> prepare ()
- php - i want to display the category name (there may be more than one) and the tag (one) in wordpress popular posts without a li
- php - wordpress says i got an important error and can't install
Are you sure that the permissions are valid (whether
current_user_can
passes in index.php)?I think it's code that seems to work if it's OK, but
wp_login
accepts aWP_User
object as an argument, so try it out.【user.php in tags/5.3/src/wp-includes – WordPress Trac】
https://core.trac.wordpress.org/browser/tags/5.3/src/wp-includes/user.php#L110