Frontend Submissions Developer Documentation
Frontend Submissions has a number of features that can be used programmatically.
Make a User a Vendor
Frontend Submissions has a helper function called make_user_vendor() which does two things at once:
- makes a user into a vendor
- changes the status on that new vendor to Approved
EDD_FES()->vendors->make_user_vendor( $user_id );
Important: the ID parameter used above is the WordPress user ID.
Change a Vendor’s Status
There are three statuses that a Vendor may have:
There are also two actions that may be taken:
All of these use the same method, but statuses and actions are different things. Here’s how it works.
First you must instantiate an Frontend Submissions object like one of these:
// Example showing required input $vendor = new FES_Vendor( $_id_or_email = false, $by_user_id = false );
// using a vendor ID $vendor = new FES_Vendor( 14, false ); // using the email address associated with the vendor ID $vendor = new FES_Vendor( 'email@example.com', true );
Secondly, you run the
change_status() method on that object, similar to one of these examples:
// Example showing required input $vendor->change_status( $new_status = '', $in_admin = false, $output = false );
$in_admin input allows you to declare whether this action should be allowed in the context of admin area, or outside of it. You may wish to allow this change inside the admin area, but not outside the admin area for example.
// Set a vendor to approved, inside the admin area, with no output $vendor->change_status( 'approved' ); // Set a vendor to pending, outside the admin area, with no output $vendor->change_status( 'pending', true ); // Set a vendor to suspended, outside the admin area, with no output $vendor->change_status( 'suspended', true, true );
In addition to the above status changes, you can run these actions:
// Revoke a vendor, inside the admin area, with no output. // This will effectively make a user NOT a vendor, and remove all their products. $vendor->change_status( 'revoke' ); // Changes a user from suspended to approved. At this point identical to setting // a user to approved, but in the future may contain some additional features. $vendor->change_status( 'unsuspend' );