Submitting front-end form from custom plugin as a Member (not Admin)
-
I am developing a plugin that has a front-end form to be submitted by registered users with a community role of “Member” and then get inserted to a custom database, users with community role “Admin” cannot submit this form.
The problem is I’m getting 302 redirects when submitting the particular form with a Member account. However, submitting with an Admin account works fine and successfully inserts data to the custom database table. I’m not really sure which options to turn on/off in the UM settings to allow a role to submit my custom form. I hope someone can help me with this.
Here is how my form looks like:
<form action="https://localhost/mysite/wp-admin/admin-post.php" method="post" class="delivery-form"> ... And this is how the database function is added to a hook:
if( class_exists( ‘DragonDB’ ) ) {
$db = DragonDB::getInstance();
}
add_action( ‘admin_post_schedule_delivery’, array( $db , ‘insert_schedule_request’ ) );I’ve also tried the admin_post_nopriv hook, but both Admin and Member couldn’t submit.
TL;DR I need a custom community role similar to a Member that allows form submissions using admin-post.php (it appears only Admin has this) but no back-end access.
- The topic ‘Submitting front-end form from custom plugin as a Member (not Admin)’ is closed to new replies.