Using admin-post.php with "Redirect Members away from the Default Profile Panel"

Wrote a custom plugin to process several HTML forms via admin-post.php, which is part of /wp-admin/. After installing s2Member Pro with

s2Member/General Options/Member Profile Modifications/
Redirect Members away from the Default Profile Panel?

set to ‘Yes’, only admin accounts can submit those forms. This is due to s2Member protecting all /wp-admin/ areas, including admin-post.php.

Please suggest solutions so that any user above Free Subscriber can submit forms. Ideally, I’d like to continue using existing plugin code to submit forms to admin-post.php while maintaining s2Member protection of /wp-admin/ areas. If that is not possible, please point me in the right direction to work around this.

Thanks in advance.

Just an idea: Look at s2M’s code, you may find good filter/hook to escape this file/URL.

Why are you processing them via admin-post.php? I think you are over-complicating things.

Just use action="" and hook the processing of the form to either the init or template_redirect hooks.

Thanks, Krum. I will look further into this approach.

Thanks, Tim.

This is only my second WP site, so I have a lot to learn. Google searches originally led me to admin-post.php as being the proper way to handle non-plugin forms. It worked well on the first site – and the second until we lusted after that S2Member protection option.

I think you are over-complicating things.

I think you are 100% correct. It’s a bad habit, that.

Just use action="" and hook the processing of the form to either the init or template_redirect hooks.

I did look into ‘init’, but the consensus seemed to be paying a price on all pages to handle a few. I have not yet looked into ‘template_redirect’, I will do that. One of these options may be where I land.

That will still apply to template_redirect if you don’t change anything else. But you can just use a conditional – i.e. something like
if ( is_page( 'blah') ) {
or
if ( !is_user_logged_in() ) {
– to avoid that problem on either hook.