1. Home
  2. ReHub Theme
  3. User submit, memberships, profiles
  4. How to make all submitted products as external automatically

How to make all submitted products as external automatically

In some cases, if you use our (or any other) frontend form plugin, you may want to make all woocommerce products to be external by default. This is, for example, if you want to create user generated affiliate websites. Problem is that default woocommerce products are always as “Simple” type, not external. This code will make product as external

add_action('wpfepp_form_actions', 'rh_make_ext_product_default');
function rh_make_ext_product_default($data){
   wp_set_object_terms($data['post_id'], 'external', 'product_type', false );  
}

You can add this code to functions.php of child theme or grandchild plugin

How to customize theme

If you need this only for one form, change wpfepp_form_actions to wpfepp_form_1_actions where 1 is ID of form

You can also use meta key _product_url if you want to add external url field to form

Was this article helpful to you? Yes No

How can we help?