Allow a user to become inactive

By: Richard Mudd | Asked: 05/09/2023
ForumsCategory: Code SnippetsAllow a user to become inactive
Richard Mudd asked 1 year ago
On the Registration form, I have a radio button that captures the user's Registration Status (Active/Inactive) defaulted to Active. I have set up a Page/form that allows the user to select a radio button that says "inactivate".  When selected and the submit button is clicked, I have code that open a page/form that asks them to confirm their choice.  The form has a User id field and the current value of the user's registration status.   when they confirm by clicking on the submit button, I am trying without success to run a hook (snippet) that flips the Registration form field Registration Status to Inactive. Can someone please help define which hook to use?         
1 Answers
Walter JonesWalter Jones answered 1 year ago
Are you trying to deny their access to Wordpress?  Or are you using user meta to filter views?
Richard Mudd replied 1 year ago

I want the user to be able to inactive their registration account by selecting a radio form button which open a page with an embedded form that lets them confirm their intention to inactivate. Inactivate means flipping a radio button on the registration form from Active to Inactive. Does this help?

Victor Font replied 1 year ago

That doesn't answer Walter's question. Besides, your original question is a little confusing. Let me see if I can restate the problem as I understand it. You have a user registration form. You don't mention if you are using the User Registration Add-on, so I'm making the assumption that it is installed and you the trigger actions set for Entry is Created, Entry is Updated. Is that correct?

For some unknown requirement, you are using a separate form to confirm the first? Why are you doing it this way?

In your post, you say, "On the Registration form, I have a radio button that captures the user's Registration Status (Active/Inactive) defaulted to Active."

This statement is clear. You have a toggle that sets Active/Inactive status. Here's where the question gets muddy.

Where are you storing the value of that toggle? Are you writing it to the WordPress User Meta Data or storing it only with the form entry?

"When selected and the submit button is clicked, I have code that open a page/form that asks them to confirm their choice."

My assumption is that you mean the submit button on the Registration Form. When the registration form entry is submitted you have custom code somewhere that opens another page with a separate form. Where are you firing the code from? What Formidable hook are you using? Or, are you just redirecting through the confirmation action?

Since you're triggering your custom code from the Registration Form submit action, the registration entry would have already been saved. You would have to save the toggle in the second form then use the frm_after_create_entry hook to update the user meta data.

Are you confirming both Active and Inactive status? Even though it appears you are passing parameters from the first to second form, the forms are not tied together, nor is the second one tied to the Registration Entry. You would also have to update the entry meta for the registration entry.

As for Walter's question, I think he's assuming you're using the User Registration Add-on, also. He is asking if you want to prevent users from logging back into WordPress if their user account status is inactive in addition to using the status as a view filter to restrict access to conntent. If you do want to restrict login, that's a different customization.

I hope this all helps.

Richard Mudd replied 1 year ago

I apologize for not being clear. Let me try again.

1. When a user registers, a radio button field on the registration form call "Registration Status" is defaulted to "Active". The other choice is "Inactive"

2. I have a second form which I call the User's Portal which has a Radio button (set as buttons) that allows the user to make a selection and then select "Submit" which then uses a hook to direct the user to a page that provides the functionality for the selection.

3. One of the choices is to "Deactivate" their registration

4. When selected, a page with an embedded form is opened that captures the current Registration Status and if it is "Active", allows them to confirm that they want to Deactivate their registration by selecting submit.

My issue is that I don't know what hook to use. I have an Update SQL statement that works perfectly in my host's database sql window and it would be great if I could integrate this into a formidable hook. I am also open to a different solution.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right