The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
About Permissions , Login Redirect, & Invoice - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Off-topic Discussions (https://userspice.com/forums/forumdisplay.php?fid=10)
+--- Thread: About Permissions , Login Redirect, & Invoice (/showthread.php?tid=1127)



About Permissions , Login Redirect, & Invoice - Ferguson230 - 08-28-2018

Hello,
I just installed UserSpice and I have a few questions. Thank you.

1. What should I do to enable users to be able to message the Admin? (Because currently, users are able to message fellow users only, when they click on the message button).

2. Is there a way to display the username, and redirect users onto the page they were on my website (eg. about-us.php) once they are successfully logged in?

(As in the attached picture below).

3. Is there a way for the Admin to create an invoice for users?


RE: About Permissions , Login Redirect, & Invoice - Brandin - 08-29-2018

1. the primary admin account is more than likely exempted from messages. Go to the appropriate User Management page for the admin (UID 1 more than likely) and click "Misc Settings", un check and save.

2. My recommended implementation of this is to track the users last page in the PHP Session using similar code to the reAuth and verifyAdmin functions in us_helpers and admin_verify.php to create the tracking and redirect upon login.

3. You would need to build this.

Thank you,
Brandin.


RE: About Permissions , Login Redirect, & Invoice - Ferguson230 - 08-30-2018

<?php
/**
* Redirecting users on login based on user role
*/
function my_login_redirect( $url, $request, $user ){
if( $user && is_object( $user ) && is_a( $user, 'User' ) ) {
if( $user->has_cap( 'administrator' ) ) {
$url = admin_url();
} else {
$url = home_url('/users-only/');
}
}
return $url;
}
add_filter('login_redirect', 'my_login_redirect', 10, 3 );

?>

Will that work for a redirect page?


RE: About Permissions , Login Redirect, & Invoice - Brandin - 08-30-2018

None of that code looks UserSpice applicable. Look at the verifyAdmin and reAuth functions for some guidance.