Skip Navigation

[Resolved] wpv-conditional with forcing lowercase?

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user was doing a comparison between the post title and the user information however the conditional code would not work since the case is different for each.

Solution:

You can actually use the strtolower() php function to do this. I went ahead and wrapped this in a shortcode for you to use.

// Add Shortcode
function lowercase( $atts ) {
 
    // Attributes
    $atts = shortcode_atts(
        array(
            'string' => '',
        ),
        $atts
    );
 
    return strtolower($atts['string']);
 
}
add_shortcode( 'lowercase', 'lowercase' );

Add this to the Toolset custom code section in Toolset -> Settings -> custom code and activate it. The next thing you need to do is add it to the views 3rd party shortcode arguments in toolset->settings-> frontend.

An example usage is

[lowercase string="[wpv-current-user info='login']"]

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 3 replies, has 2 voices.

Last updated by Sammut 1 year, 4 months ago.

Assigned support staff: Shane.

Author
Posts
#1246038

I am running into an issue. I have a conditional

[wpv-conditional if="( '[wpv-current-user info='login']' eq '[wpv-post-title output='sanitize']' )"]

We are matching the user's login with a page title. However, users are using mixed case on their login and it does not match the title. IS there any way to force lowercase on both current-user and post-title, in the example above, just in the condition to see if we have a match?

Thank you!

#1246090

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Sammut,

Thank you for getting in touch.

You can actually use the strtolower() php function to do this. I went ahead and wrapped this in a shortcode for you to use.

// Add Shortcode
function lowercase( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'string' => '',
		),
		$atts
	);

	return strtolower($atts['string']);

}
add_shortcode( 'lowercase', 'lowercase' );

Add this to the Toolset custom code section in Toolset -> Settings -> custom code and activate it. The next thing you need to do is add it to the views 3rd party shortcode arguments in toolset->settings-> frontend.

An example usage is

[lowercase string="[wpv-current-user info='login']"]

Please let me know if this helps.
Thanks,
Shane

#1246191

Works like a charm!!!!!!! THANK YOU! I am glad to know this method for the future!

#1246192

My issue is resolved now. Thank you!