Jump to content

Stefan83

Members
  • Posts

    24
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Stefan83's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi I'm getting a undefined index error because I belive I need to check if inApp exists before calling it. This is what I have, how do I rewrite? Do I need if (isset.....? <?php if ( 'yes' == get_field('hide_header_and_footer') || ($_GET['inApp'] == '1') ): // Do stuff endif; ?> Thanks
  2. Hi Can anyone tell me what is wrong with the code below? I'm getting a Warning: Illegal string offset 'redirect' in... error in this line: if (preg_match("/aeid/", $confirmation['redirect'])){ I've just updated php to 5.4 and I get the error when I submit a gravity form for wordpress via ajax function salesmod_confirm_change($confirmation, $form, $lead, $ajax){ if (preg_match("/aeid/", $confirmation['redirect'])){ if (!$_GET['cfn']) { $confirm_id = substr(md5( substr(md5(time()), 0, 16)), 0, 16); gform_update_meta($lead['id'], 'confirmation_id', $confirm_id); } else { $confirm_id = $_GET['cfn']; } $confirmation = array('redirect' => $confirmation['redirect'] . "&cfn=" . $confirm_id); } return $confirmation; } Thanks
  3. Thanks for the replies, managed to solve it in the end. Here's my final code if anyone interested // Added custom validation for maximum characters count add_filter("gform_field_validation_24_47", "validate_chars_count", 10, 4); function validate_chars_count($result, $value, $form, $field){ $street = $value["47.1"]; $city = $value["47.3"]; $country = $value["47.6"]; $zip = $value["47.5"]; if (empty($street) && empty($city) && empty($country)){ $result["is_valid"] = false; $result["message"] = "This field is required. Please enter your full address."; } if (strlen($zip) > 20) { // Maximum number of characters $result["is_valid"] = false; $result["message"] = "Post Code must be no more than 20 characters."; } return $result; }
  4. Hi I'm trying to limit the number of characters in a postcode field in wordpress gravity form. This is what I have so far but its not working. add_filter("gform_field_validation_24_47", "custom_validation"); function custom_validation($result, $value, $form, $field){ if(!$result["is_valid"] && $result["message"] == "Enter full address."){ $zip = $value["47.5"]; if(strlen($zip) > 10) { $result["is_valid"] = false; $result["message"] = "Max 10 characters"; } } return $result; } Can anyone tell me what the issue is? Thanks!
  5. Hi - I'm using Wordpress gravity forms plugin. I'd like to force capitalise and remove the spaces within a specific field. This is what I have but its not working. $_POST[$each] = strtoupper(rgpost($each)) works for making the characters capitals but adding && str_replace(' ', '', $each) after doens't work. What am I doing wrong? Thanks add_action('gform_pre_submission_22', 'capitalize_fields'); function capitalize_fields($form){ $fields_to_cap = array( 'input_64' ); foreach ($fields_to_cap as $each) { $_POST[$each] = strtoupper(rgpost($each)) && str_replace(' ', '', $each); } return $form; } ?>
  6. Hi - How do I convert the following to an array? if( (isset($_GET['full']) && $_GET['full'] == 1) || (isset($_GET['fromApp']) && $_GET['fromApp'] == 1) || (isset($_GET['fromQB']) && $_GET['fromQB'] == 1) || (isset($_GET['fromAW']) && $_GET['fromAW'] == 1) || (is_page_template('dec13.php')) || (false !== strpos($url,'hire'))) { } else { }
  7. HI I'm building a splash page that mobile users are redirected to when they visit a page on my website. from=(Original URI) is added the splash page's URL. There is a link at the bottom of the splash page which gets the value of the 'from' query to allow the user to click back to the orginal page. I'm trying to build a URL for this link with the following script so '?full=1' query string is appended to the end of the URL. Here's the code: <?php $qstring = array('full'=>'1' ); ?> <a href="<?php bloginfo('url'); echo htmlspecialchars($_GET["from"]); ?>?<?php echo http_build_query($qstring) . "\n"; ?>">Continue to Website</a> - get the current URL of a Wordpress site (eg http:www.domain.com) - echo the value of 'from' query (eg from=orginalpage) - and append the full=1 The problem is if there is a query string already in the from URI from original page , I get an unwanted duplicate '?' in the URL. So if the original URL is http://www.domain.com/orginalpage/?test=1 would redirect to http://www.domain.com/splashpage/?from=orginalpage/?test=1 So the link looks like http://www.domain.com/orginalpage/?test=1?full=1 How do I stop the duplicate '?' and replace with '&'? Thanks
  8. Thanks guys, that's great. Now, on the mobile landing page, I'd like include different content based on referral URL. So if the URL is domain.com/mobile/?from=%2F%3Fnov13%3Dtest1 I'd like to load nov13.php But I'd also like to load nov13.php file when the value is test2, test3 etc. How do I rewrite the array below for this wildcard variable? <?php $mapping = array( '%2F%3Fnov13%3Dtest1' => 'inc/mobile/nov13.php' '%2F%3Fnov13%3Dtest2' => 'inc/mobile/nov13.php' '%2F%3Fnov13%3Dtest3' => 'inc/mobile/nov13.php' '%2F%3Fnov13%3Dtest4' => 'inc/mobile/nov13.php' ); if(array_key_exists($_GET['from'], $mapping)) include $mapping[$_GET['from']]; else include 'inc/mobile/default.php'; ?> Thanks
  9. Hi I'm redirecting wireless devices to a page that delivers different content based on the device OS. I'm using WURFL to do this. The following code gets the landing page URI and redirects mobile devices to domain.com/mobile/?from=previousPageURI elseif ($client->getDeviceCapability('is_wireless_device')) { $source = ''; if(isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] != '/'); $source = urldecode($_SERVER['REQUEST_URI']); header("Location:/mobile/?from=$source"); } The issue I'm having is if the referral URL already has a query string attached, I get two '?' in the URL. So domain.com/?example=1 redirects to domain.com/mobile?from=?example=1 How do I resolve this? Thanks
  10. Thanks, BrodaNoel Unfortunately this only displays the default.php content. So to confirm. If the URL is www.domain.com/mobile/?from=/booknow, the booknow.php file should be displayed, else default.php $mapping = array( '/booknow' => 'inc/mobile/booknow.php', ); if($mapping[$_GET['from']] != '') include $mapping[$_GET['from']]; else include 'inc/mobile/default.php'; Where am I going wrong? Thanks
  11. Hi BRodaNoel Thanks for your reply! That's great. How do I replace the echo with include? I can't get this to work: $mapping = array('/page1' => 'inc/mobile/content1.php', '/page2' => 'inc/mobile/content2.php', '' => 'inc/mobile/default.php'); include $mapping[$_GET['from']];
  12. Hi - I'm trying to display different content based on the query string variable. for example if URL contains domain.com/?from=/page1 show content1 else if URL contains domain.com/?from=/page2 show content2. This is what I have so far but I'm not sure what's wrong. Any ideas? if ( (isset($_GET['from']) && $_GET['from'] == '/page1')) { echo 'content1'; } elseif( (isset($_GET['from']) && $_GET['from'] == '/page2')) { echo 'content2'; } else { echo 'default'; }
  13. Hi - I'm trying to echo different results if the current URL contains a certain query string. Ie if the URL contains ?fromAPP=1 OR ?fromQB=1 DO SOMETHING. I can't get the following to work. Can anyone help? Thanks $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (false !== strpos($url,'?fromApp=1,?fromQB=1')) { // do something } else { }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.