Hi
I recommend this change at file assets/js/admin.js from:
jQuery( ‘.mtral .block label select’ ).on( ‘change click’, function(e){
let custom_link = jQuery(this).children(“option:selected”).attr(‘custom-link’)
let val = jQuery(this).children(“option:selected”).val()
if( custom_link !== undefined ){
jQuery( this ).closest( ‘label’ ).closest( ‘.block’ ).find( ‘label input[type=”text”]’ ).val( val );
}else{
jQuery( this ).closest( ‘label’ ).closest( ‘.block’ ).find( ‘label input[type=”text”]’ ).val( ” );
}
}).change();
to:
jQuery( ‘.mtral .block label select’ ).on( ‘change click’, function(e){
if (jQuery(this).is(‘:disabled’)==false) {
let custom_link = jQuery(this).children(“option:selected”).attr(‘custom-link’)
let val = jQuery(this).children(“option:selected”).val()
if( custom_link !== undefined ){
jQuery( this ).closest( ‘label’ ).closest( ‘.block’ ).find( ‘label input[type=”text”]’ ).val( val );
}else{
jQuery( this ).closest( ‘label’ ).closest( ‘.block’ ).find( ‘label input[type=”text”]’ ).val( ” );
}
}
}).change();
At Admin page, after save the settings, the custom url value revert to to home page url.
At database the settings is OK, and the redirect works.
The only problm was at admin page.
Regards
Kostas
Hi, Your Plugin was recommended, but unfortunately, every time I try to add a new page under either Subscribers or Contributors it will never save the information.
Regards
Drachs
I migrated my site but now my admin doesn’t work. I enter the access data and he does not direct me to the dashboard, I tried to restart the .htaccess and it has not been possible I need urgent help.
]]>the website I use is multisite with sub-directory, the main website successfully redirect to the homepage, but on multisite still not managed to redirect to homepage
]]>hey!
i want to redirect users to a custom link, their buddypress profile! this has the URL: https://wolkify.com/members/%5Busername%5D
is there a way i can add the [username] part so that the plugin understands that? that would help me a ton!
thank you! moritz
]]>After changing the options for this plugin, I get these error notices:
Notice: Undefined index: mtral_field_editor in /wp-content/plugins/redirect-after-login/classes/options.php on line 306
Notice: Undefined index: mtral_field_author in /wp-content/plugins/redirect-after-login/classes/options.php on line 306
Notice: Undefined index: mtral_field_contributor in /wp-content/plugins/redirect-after-login/classes/options.php on line 306
Notice: Undefined index: mtral_field_subscriber in /wp-content/plugins/redirect-after-login/classes/options.php on line 306
Notice: Undefined index: mtral_field_employer in /wp-content/plugins/redirect-after-login/classes/options.php on line 306
Notice: Undefined index: mtral_field_translator in /wp-content/plugins/redirect-after-login/classes/options.php on line 306
Notice: Undefined index: mtral_field_wpseo_manager in /wp-content/plugins/redirect-after-login/classes/options.php on line 306
Notice: Undefined index: mtral_field_wpseo_editor in /wp-content/plugins/redirect-after-login/classes/options.php on line 306
]]>Hello,
Title says it all. This plugin shows an error message upon activation.
Could you update the plugin to fix this notice?
]]>This does work provided you put the correct information into the “Custom URL” box. The plugin will append whatever you put into the box, to the site default URL. So usually all you need to include is the file which is the default file run when opening custom site. i.e. “index.php” or “index.html” or whatever.
]]>The plugin is fine if used under a specific set of circumstances. However, when used with a system that uses a login on the front end, it does not work. This is due to some flaws in the filter function that could be corrected quite simply. There are two specific issues.
First, your filter function assumes the user object is global, which it is not until the user is set as logged in, which does not occur in all cases until page reload. Since the user object is actually passed through the filter, you should retrieve it that way instead of relying on it being global (since that way it may be empty which causes your is_array() check to return false).
Interestingly, your call for the filter passes the filter’s three arguments:
add_filter("login_redirect", "redirect_after_login_per_role", 10, 3);
Yet you don’t pick up any of those in the callback:
function redirect_after_login_per_role()
If you would just change callback to pick up the passed arguments it would solve that issue:
function redirect_after_login_per_role( $redirect_to, $request, $user )
The other issue is related in that without picking up the $redirect_to argument when the method is declared, you end up returning an empty value if none of the function’s conditional statements resolve. It needs to return the filter variable ($redirect_to in this case) in the event that the filter function’s logic doesn’t end up doing anything. For this you need to be picking up the $redirect_to argument in the filter’s callback and also returning it unfiltered at that end in case the logic results in false.
Changing the function accordingly would improve your compatibility and would resolve the issues described in some of the 1 star reviews:
function redirect_after_login_per_role( $redirect_to, $request, $user )
{
//retrieve current user info
global $wp_roles, $user;
$roles = $wp_roles->roles;
$setting = get_option('mtral_settings');
//is there a user to check?
foreach($roles as $role_slug => $role_options){
if( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if( in_array( $role_slug, $user->roles ) ) {
$admin_pages = $setting['mtral_field_'.$role_slug];
$admin_custom_pages = $setting['mtral_field_custom_url_'.$role_slug];
$redirect = (empty($admin_custom_pages)) ? get_admin_url().$admin_pages : $admin_custom_pages;
// redirect them to the default place
return $redirect;
}
}
}
return $redirect_to;
}
]]>
Redirecting to custom URL not working. Only option for subscribers is dashboard. Can’t redirect anywhere else.
]]>… instead it goes to the dashboard as usual. Could this be because there is no way to choose a blank entry in the drop-down list box?
Phil Gardner
]]>