baddon250
Forum Replies Created
-
If I could run something inside the given functions I have, that would be best.
What do I do with $this->set_mode.
Keep in mind I will have multiple different links with the associated fields below.
One for Website.
One for Phone Number
One for Toll-Free Phone Number
One Sales Icons
One for Gallery Sorting
You’re probably going to end up doing something like this anyways, so maybe its a good time, because theres a lot of companies that run a SAAS busines model like we do, and one of our products resides on displaying certain fields on profiles.
Do you think you could alter those 2 functions to be replaced with these 2 functions?
/** * Print field error * * @param string $text * @param bool $force_show * * @return string */ function field_error( $text, $force_show = false, $allow_html = false ) { if ( empty( $text ) ) { return ''; } if($allow_html){ $data = wp_kses_post($text); } else{ $data = esc_attr($text); } if ( $force_show ) { $output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . $data . '</div>'; return $output; } if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) { $output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . $data . '</div>'; } else { $output = ''; } if ( ! UM()->form()->processing ) { $output = '<div class="um-field-error"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . $data . '</div>'; } return $output; } /** * Print field notice * * @param string $text * @param bool $force_show * * @return string */ function field_notice( $text, $force_show = false, $allow_html = false ) { if ( empty( $text ) ) { return ''; } if($allow_html){ $data = wp_kses_post($text); } else{ $data = esc_attr($text); } if ( $force_show ) { $output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . $data . '</div>'; return $output; } if ( isset( $this->set_id ) && UM()->form()->processing == $this->set_id ) { $output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . $data . '</div>'; } else { $output = ''; } if ( ! UM()->form()->processing ) { $output = '<div class="um-field-notice"><span class="um-field-arrow"><i class="um-faicon-caret-up"></i></span>' . $data . '</div>'; } return $output; }Is there any way you can make a change to that function to give it the option to bypass that esc_attr for custom options like this. I’m sure im not the first and I definitely won’t be the last. Forwarding is not an option because it would feel forceful and unexpected to the user.
I would do it on my end, but then it would be rewritten the next update.
Mayble replace esc_attr with wp_kses_post to allow for some basic html usage when the option is selected.
- This reply was modified 3 years, 5 months ago by baddon250.
Did you get a chance to look at this?
There is something in your add_error function that is overriding my input. I tried to echo the error message and it is outputting properly when echo’d to the top of the page, but it needs to work on your add_error function to get to the right function. add_error is forcing the html to get written as a string of text. Here is a screenshot of my page, and here is the current function that I have, this function should be working, but there is a glitch on the add_error function on your end.
function bp_custom_validate_website( $key, $array, $args ) { $key_product = array( 'page_url' => 37081, 'headline' => 37080 ); //37082 = toll-free-number // if ( isset( $args[$key] ) && !is_active_subscription( $key_product[$args[$key]] ) ) { $url = get_site_url() . '/product/use-toll-free-phone-number'; $error = sprintf( wp_kses( __( 'Add-On Not Enabled <a href="%s">CLICK HERE</a> to get the Add-On.', 'ultimate-member' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( $url ) ); //$error = 'Add-On Not Enabled, '. $link .' to get the Add-On.'; UM()->form()->add_error( $key, $error ); //} } add_action( 'um_custom_field_validation_validate_website', 'bp_custom_validate_website', 30, 3 );I tried a handful of different ways, but what I was finding was that the default function of error message was overriding what I was doing, even when I used sprintf function for __() function
But I gotta make it easy for the user 🙁
And here’s a php beautifier so you’re not looking at wordpresses hard to read formatting.
Here’s the screenshot of the page, we have products that relate to certain fields being activated, so there are going to be 3 different message links total to get the user to the right location.
function is_active_subscription($product){
$output = false;
if(is_user_logged_in()){
/*
$subscriptions = array(
37084, //sort gallery images
37082, //use toll-free number
37081, //link to website
37080, //sales icons
35624, //builder membership um_paid-member
35623, //growth membership um_premium-member
35622, //starter membership um_member
37079 //profile setup
);
*/
//for the growth plan with premium member status$growth_included_subscriptions = array(
37084,37082,37081,37080,37079
);$user = wp_get_current_user();
$user_id = $user->ID;
$profile_builder = false;
$profile_builder_roles = (‘manager, administrator, um_profile-builder’);if(wcs_user_has_subscription($user_id, $product, ‘active’) || user_has_role(‘um_profile-builder’) || user_has_role(‘administrator’) || user_has_role(‘manager’)){
$output = true;
} else if(is_contractor_role(‘um_premium-member’)){
for($i=0; $i<sizeof($growth_included_subscriptions); $i++){
if($growth_included_subscriptions[$i] == $product){
$output = true;
}
}
}}
return $output;
}And if it helps I’m going through the functions.php of the themes folder.
I’m still getting the same result. Any other ideas?
RESULT
Add-On Not Enabled, CLICK HERE to get the Add-On. helloI can’t get it working, here’s what i’ve got.
function um_custom_validate_website( $error, $key) { //$val = $args[$key]; $keys = array('page_url'); $key_product = array('page_url' => 37081, 'headline' => 37080); if(is_active_subscription($key_product[$key])){//37082 = toll-free-number } else{ $link = get_site_url(). '/product/toll-free-phone-number'; /*if(!strpos($val, "http://") && !strpos($val, 'https://')){ UM()->form()->add_error( $key, __( "Please add: https:// or http://", 'ultimate-member' ) ); }*/ my_submit_form_error('Add-On Not Enabled, <a href="'. $link .'">CLICK HERE</a> to to get the Add-On.', $key); //UM()->form()->add_error( $key, __( "Add-On Not Enabled, Go to your Profile Add-Ons on your Profile Menu to add. Top-Right of the Page", 'ultimate-member' ) ); } } add_action( 'um_custom_field_validation_validate_website', 'um_custom_validate_website', 30, 3 ); add_filter( 'um_submit_form_error', 'um_custom_validate_website', 10, 2 ); function my_submit_form_error( $error, $key ) { return $error; }Forum: Plugins
In reply to: [Asset CleanUp: Page Speed Booster] GLITCHAnd I didnt mean to say ajax enabled, I meant to say async loading