No reset password for selected group

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
Melroy
Posts: 21
Joined: 2015-06-10 12:59

No reset password for selected group

Post by Melroy » 2018-01-29 16:14

Hi,
I am using version 5.7 rev 1020.

How can I stop one particular group ("members") from resetting the password which is assigned annually by admin. I have very little coding experience but am happy to insert/delete scripts kindly provided by others.

R Tammam
Veteran Member
Posts: 113
Joined: 2017-08-26 15:35

Re: No reset password for selected group

Post by R Tammam » 2018-02-19 00:26

Hello Melroy,

the reset password section appears in 2 case
1- membership_profile.php
2- in the login page

for the first case , you can add a piece of code in footer extras page , to detect the user group, and if he is one of who are not allowed hide the reset passowrd for him

and for the second case , in membership_passwordReset.php , you can use the email or the user name to detect the user group
and if he is a member of a group who are not allowed to reset their passwords , redirect him to the home page

Melroy
Posts: 21
Joined: 2015-06-10 12:59

Re: No reset password for selected group

Post by Melroy » 2018-02-23 11:18

Hi R Tammam,
Thank you for your reply which is very helpful as it will direct me to the areas where I can add/edit the code. Now I just need to work out what piece of code I need. I would appreciate any help from anyone on this please.

R Tammam
Veteran Member
Posts: 113
Joined: 2017-08-26 15:35

Re: No reset password for selected group

Post by R Tammam » 2018-03-28 20:34

Hello Melroy,
here's the code you will need , it works for me
you will put it into membership_passwordReset.php
the position of the code will be from line 110 to 127
https://www.screencast.com/t/2yFtbNRqeU

and here's the code
youw will only change $not_allowed_groups = array ('students'); with your not allowed students

Code: Select all

	$not_allowed_groups = array ('students');
		if( $username ){
			$reset_coulmn = "memberID";
			$reset_value = $username;
		}else if ( $email ){
			$reset_coulmn = "email";
			$reset_value = $email;
		} 
		
		$query = "select membership_groups.name from membership_groups,membership_users 
			where  membership_users.groupID = membership_groups.groupID and {$reset_coulmn} = '{$reset_value}' ";
 		 
		$user_group = sqlValue ( $query ,$q);
		
		if ( in_array ($user_group, $not_allowed_groups) ){
			header("Location:index.php");
			exit;
		}
i hope it would help you
Regards,
Reham

Melroy
Posts: 21
Joined: 2015-06-10 12:59

Re: No reset password for selected group

Post by Melroy » 2018-04-15 11:02

Hi Reham,
Sorry for the delay in responding to your last suggestion. I will give it a try.

Many thanks
Melroy

Melroy
Posts: 21
Joined: 2015-06-10 12:59

Re: No reset password for selected group

Post by Melroy » 2018-04-15 15:33

Hi Reham,
I tried the code you provided but it did not work for me. I copied and pasted the code in position 110 changing only $not_allowed_groups = array ('students'); to $not_allowed_groups = array ('members');

I was still able to change the password for a user in the group 'members' when logged in.

I did notice that $reset_coulmn = "memberID"; might have been $reset_column = "memberID"; so I corrected it where appropriate but to no avail.

Any thoughts? Have I missed something?

Regards
Melroy

R Tammam
Veteran Member
Posts: 113
Joined: 2017-08-26 15:35

Re: No reset password for selected group

Post by R Tammam » 2018-04-18 14:41

Melory, i think there was something wrong in mentioning the place to put you code ,
so i recorded a screen cast for you explaining where to put your code for the first time and testing it on my project
https://www.screencast.com/t/mJghGyhXLc

Melroy
Posts: 21
Joined: 2015-06-10 12:59

Re: No reset password for selected group

Post by Melroy » 2018-07-04 10:01

Thank you R Tammam for your assistance, Problem has now been resolved. Sorry for not thanking you earlier.

Post Reply