Moving Signup URL with Anti-Splog Trouble

I have a pricing table plugin that I'm using to compare plan features on my site. The pricing table lets me use a shortcode in place of a URL to send visitors to a signup page, but it doesn't allow a mix of HTML and a shortcode. Since I am using the Rename wp-signup.php feature in Anti-Splog, I needed to create a custom shortcode to incorporate the <a href... HTML for the link along with the code to generate the signup page URL <?php ust_wpsignup_url(); ?>.

My new shortcode function looks like this:

function create_signup_link( $atts ) {
	$a = shortcode_atts( array(
		'text' 		=> 'Sign up Now',
		'target'	=> '_self',
		'style'		=> 'background:#8cbee3',
		'class'		=>	'rpt_foot rpt_foot_0',
		'url'		=>	ust_wpsignup_url(),
	), $atts );

	return "<a href='".$a['url']."' target='".$a['target']."' style='".$a['style']."' class='".$a['class']."'>".$a['text']."</a>";
}
add_shortcode( 'signuplink', 'create_signup_link');

However when I use the new [signuplink] shortcode in the pricing table (or in a regular page/post), it outputs the url before the text in a strange manner:

https://mysite.com/signup-26f/<a href='' target='_self' style='background:#8cbee3;' class='rpt_foot rpt_foot_0'>Sign Up Now</a>

I am using the [ust_wpsignup_url] shortcode elsewhere on my site and it's working fine. I'm not sure what is causing the custom shortcode to behave strangely though.

Edit: Using the [ust_wpsignup_url] shortcode in the pricing table's URL field gives me the url for the page plus the shortcode http://mysite.com/options/ust_wpsignup_url

  • Michael Bissett

    Hey @Scott, hope you're doing well today! :slight_smile:

    The issue here looks to be due to the signup URL being echoed, instead of returned, the ust_wpsignup_url() function displays the signup link on the page by default.

    You can modify the behavior here by tweaking your shortcode function to read like this:

    function create_signup_link( $atts ) {
    	$a = shortcode_atts( array(
    		'text' 		=> 'Sign up Now',
    		'target'	=> '_self',
    		'style'		=> 'background:#8cbee3',
    		'class'		=>	'rpt_foot rpt_foot_0',
    		'url'		=>	ust_wpsignup_url($echo = false),
    	), $atts );
    
    	return "<a href='".$a['url']."' target='".$a['target']."' style='".$a['style']."' class='".$a['class']."'>".$a['text']."</a>";
    }
    add_shortcode( 'signuplink', 'create_signup_link');

    Let me know if this helps please! :slight_smile:

    Kind Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.