Allow to use admin_post_{action} with Profil Modification set to Yes

Hi Guys,

I try to use the function admin_post_{action} in the frontend (https://codex.wordpress.org/Plugin_API/Action_Reference/admin_post_(action)). I want to generate a pdf when a user send a contact form.

In “General Options” > “Member Profile Modifications” I choosed the option Yes (redirect to Login Welcome Page; locking all /wp-admin/ areas) then the admin_post_ works only for administrators and not for others roles.

Do you know a way to fire the admin_post_ hook with this setting?

I appreciate your feedback or recomendations :slight_smile:.
Carlos

Surely the answer is not to rely on this very general WP hook, but instead to find the hook triggered specifically when your particular form is submitted.

Hi Tim,

Thank you for your answer, I will disable the option in s2member and I will block for subscribers an s2member roles the wp-admin pages.

best regards
Carlos

Interested to know how that worked out for you Carlos. I’m needing to do the same thing and I’d rather not re-write my plugin to post back with a method other than using admin-post.php though I suppose I can if I absolutely must.

When you say you were going to block subscribers roles in the wp-admin pages can you explain more about that?

Thanks,
Karla

Hi Karla,

Yes, I didn’t try anymore to use this function admin_post_{action}.
When you are in the front end of your member site, sometimes you don’t want to allow your customers to have access to the back end. For example, they can’t modify the profile on the back end, they must do that in the profile proform in the front end.

When you set “General Options” > “Member Profile Modifications” to Yes (redirect to Login Welcome Page; locking all /wp-admin/ areas), and a user tries to visit yourdomain.com/wp-admin/profile.php, he will be redirected to your Welcome page. With this option, you can’t use the function admin_post_{action} in the front end. You can maybe hook the init function instead.

Carlos