Posted on Leave a comment

Restrict Add Product without Payment Setting

You may restrict vendor’s “Add Product” permission if they not yet setup their payment setting –

add_filter( 'wcfm_is_allow_pm_add_products', function( $is_allow ) {
global $wp;
if( wcfm_is_vendor() ) {
$vendor_id = apply_filters( 'wcfm_current_vendor_id', get_current_user_id() );
$vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
$payment_mode = isset( $vendor_data['payment']['method'] ) ? esc_attr( $vendor_data['payment']['method'] ) : '' ;
$paypal_email = isset( $vendor_data['payment']['paypal']['email'] ) ? esc_attr( $vendor_data['payment']['paypal']['email'] ) : '' ;
$stripe_user_id = get_user_meta( $vendor_id, 'stripe_user_id', true );
if( !$payment_mode || ( ( $payment_mode == 'stripe' ) && !$stripe_user_id ) || ( ( $payment_mode == 'paypal' ) && !$paypal_email ) ) {
if( isset( $wp->query_vars['wcfm-products-manage'] ) ) {
wcfm_restriction_message_show( __( "Payment account not yet setup!", "wc-fronend-manager" ), false, true );
}
$is_allow = false;
}
}
return $is_allow;
}, 750 );

Leave a Reply

Your email address will not be published. Required fields are marked *