Archives: Snippets
Changing sublabels for Email Field on a Single Form
/** * Customize email field properties. * * @link https://wpforms.com/developers/how-to-change-sublabels-for-the-email-field/ */ function wpf_dev_email_field_properties( $properties, $field, $form_data ) { // Only process this snippet on the form ID 123 if ( absint( $form_data[ ‘id’ ] ) !== 123 ) { return…Continue reading
Changing Sublabels for the Email Field
/** * Customize email field properties. * * @link https://wpforms.com/developers/how-to-change-sublabels-for-the-email-field/ */ function wpf_dev_email_field_properties( $properties, $field, $form_data ) { // Change sublabel values $properties[ ‘inputs’ ][ ‘primary’ ][ ‘sublabel’ ][ ‘value’ ] = __( ‘Enter Your Email’, ‘plugin-domain’ ); $properties[ ‘inputs’…Continue reading
Make the auction start price and auction dates required for vendors
/* WCV – Require auction start price and auction dates */ function wcv_make_field_required( $field ) { $field[‘custom_attributes’][‘required’] = ‘required’; $field[‘custom_attributes’][‘data-parsley-required-message’] = __( ‘This field is required.’, ‘wc-vendors’ ); return $field; } add_filter( ‘wcv_simple_auctions_end_date’, ‘wcv_make_field_required’ ); add_filter( ‘wcv_simple_auctions_start_date’, ‘wcv_make_field_required’ ); add_filter(…Continue reading
MemberPress: Free-Views-Left Counter
function mepr_display_cookie() { if ( isset( $_COOKIE[‘mp3pi141592pw’] ) && ! empty( $_COOKIE[‘mp3pi141592pw’] ) ) { $cookie = $_COOKIE[‘mp3pi141592pw’]; $mepr_options = MeprOptions::fetch(); $num_views = base64_decode( $cookie ); if ( $num_views < $mepr_options->paywall_num_free_views ) { $free_views = $mepr_options->paywall_num_free_views – $num_views; echo ‘You…Continue reading
MemberPress: Redirect To Specific Page Based on Rule
function mepr_redirect_specific_page( $redirect_url, $delim, $uri ) { $current_post = MeprUtils::get_current_post(); $rules = MeprRule::get_rules( $current_post ); if ( !empty( $rules ) ) { $rule_ids = array_column( $rules, ‘ID’ ); if ( in_array( 123, $rule_ids ) ) { $redirect_url = ‘https://yourdomain.com/register/membership-1/’; }…Continue reading
MemberPress: Disable Unauthorized Redirection on a Specific Page or Post
function mepr_stop_unauthorized_redirect( $redirect, $url, $delim ) { global $post; if( $post->ID === 123 ) { $redirect = false; } return $redirect; } add_filter( ‘mepr-pre-run-rule-redirection’, ‘mepr_stop_unauthorized_redirect’, 10, 3) ;Continue reading
MemberPress: Disable the Unauthorized Redirection for Multiple Pages And/or Posts
function mepr_stop_unauthorized_redirect( $redirect, $url, $delim ) { global $post; if(in_array($post->ID, array( 123, 456, 789 ) ) ) { $redirect = false; } return $redirect; } add_filter( ‘mepr-pre-run-rule-redirection’, ‘mepr_stop_unauthorized_redirect’, 10, 3 );Continue reading
Memberpress: Remove the Navigation Links on Page
.memberpressproduct-template-default .navigation.post-navigation { display: none; }Continue reading
Using Conditional Logic to Change Date Picker Locale
/** * Conditionally apply the date picker locale strings, depending on what the * current locale is as defined by WPML. * * @link https://wpforms.com/developers/localize-the-date-picker-strings/ */ function wpf_dev_datepicker_apply_locale() { if ( defined( ‘ICL_LANGUAGE_CODE’ ) && ‘es’ == ICL_LANGUAGE_CODE ) {…Continue reading