Frontend Submissions Developer Documentation
Frontend Submissions has a number of features that can be used programmatically. Here we'll take a look at each.
Make a User a Vendor
FES 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 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 FES 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( 'firstname.lastname@example.org', 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' );