Pinegrow Community Support Forum

Running custom php script


#1

Hello everyone,

I have obtained this script:

/**
 * SWAP THE LOGIN/LOGOUT LABELS WITH ICONS
 * this will apply to any login/logout link which is built using wp_loginout()
 * remember to ensure that 'Login' and 'Logout' in the function are the same labels used in your theme
 *
 * @param	$link	{string}	html string of the link  (must be returned to the filter)
 *
 * Author: Andrea Piccart
 * Author Uri: http://bespokewebdeveloper.com
 */

add_filter( 'loginout', 'bwd_use_icon_on_loginout_link');

function bwd_use_icon_on_loginout_link( $link ){
	// if user is logged in
	if ( is_user_logged_in() ){
		$link = str_replace( '<i class="fa fa-sign-out"></i>', 'Logout', $link );
    echo "running logout";
	}
	else { // if user is not logged in
		$link = str_replace( '<i class="fa fa-sign-in"></i>', 'Login', $link );
    echo "running login";
	}
	// return the link
	return $link;
}

But, if I call it from the login logout function within PineGrow, it doesn’t replace the text by icons?

Anyone has any idea why it isn’t working?

Thanks!

kind regards,

Michael


#2

@24degrees I haven’t tried it but is it a possibility that it should be added to the functions.php file.


#3

I have added the code to the functions.php file. I also added an ‘echo command’ to see if the function ‘loops through’ and it actually does.