Home Wordpress admin-post.php only working if role=admin, but need subscriber role to work too
Reply: 0

Wordpress admin-post.php only working if role=admin, but need subscriber role to work too

user1240
1#
user1240 Published in June 19, 2018, 11:59 pm

On a Wordpress website, I am using admin-post.php in a form (code below) on my website to trigger an action upon submitting the form, where I can process the $_POST items and set some cookies. This works fine if I set my account role to admin, but does not work if I simply change the role to subscriber (I will need my subscribers to be able to submit this form). As subscriber role, instead of running admin-post.php, it just redirects me to the website homepage, even though I am still logged in. So it acts like admin-post.php is not executable as subscriber role, but I am not sure how to change this... maybe I need a some kind of .htaccess code in the wp-admin dir? I am stumped... any ideas?

< form method='post' action='/wp-admin/admin-post.php'>

< input type='hidden' name='action' value='run_my_wp_action'   >
//Other form items removed

<input type='submit' name='submit' value='Next' >
</form >

PHP in my WP plugin

add_action( 'admin_post_nopriv_run_my_wp_action', 'my_wp_action' );     
add_action( 'admin_post_input_run_my_wp_action', 'my_wp_action' );          

function my_wp_action() {   //code  }
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312502 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO