Support » Plugin: URL Params » Option to check if the parameter is set but empty

  • Adjusted the code a little to check if a parameter like FirstName was set but if it doesn’t contain any value : [ifurlparam param=”FirstName” notempty=1] Welcome Back [/ifurlparam]

    ============== The Code ==============

    function ifurlparam($atts, $content) {
    $atts = shortcode_atts(array(

    ‘param’ => ”,
    ’empty’ => false,
    ‘is’ => false,
    ‘notempty’ => false,

    ), $atts);

    $params = preg_split(‘/\,\s*/’,$atts[‘param’]);

    if ($atts[‘notempty’] && (strlen($_REQUEST[$param]) != 0) )
    {
    return do_shortcode($content);
    }

    foreach($params as $param)
    {
    if($_REQUEST[$param])
    {
    if($atts[’empty’])
    {
    return ”;
    } elseif(!$atts[‘is’] or ($_REQUEST[$param] == $atts[‘is’])) {
    return do_shortcode($content);
    }
    }
    }

    if ($atts[’empty’])
    {
    return do_shortcode($content);
    }

    return ”;
    }

  • The topic ‘Option to check if the parameter is set but empty’ is closed to new replies.