Patreon WordPress Shortcode

Below, you’ll find a detailed guide on how to add the Patreon WordPress Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Patreon WordPress Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Patreon WordPress Plugin and the shortcodes it provides:

Plugin Icon
Patreon WordPress

"Patreon WordPress is a powerful plugin that integrates your WordPress site with Patreon, allowing seamless connectivity between the two platforms. With Patreon-connect, enjoy streamlined content monetization."

★★★✩✩ (40) Active Installs: 4000+ Tested with: 6.1.4 PHP Version: 5.4
Included Shortcodes:
  • [patreon_login_button]

Patreon WordPress [patreon_login_button] Shortcode

The Patreon Connect plugin shortcode, ‘patreon_login_button’, enables a login button for users. It first checks if the user is connected to Patreon. If not logged in, or a Patreon ID doesn’t exist, it displays the Patreon login button.

Shortcode: [patreon_login_button]

Examples and Usage

Basic example – A simple usage of the Patreon login button shortcode. This will create a login button for Patreon users on your WordPress site.

[patreon_login_button /]

PHP Function Code

In case you have difficulties debugging what causing issues with [patreon_login_button] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'patreon_login_button', array( $this,'LoginButtonShortcode' ) );

Shortcode PHP function:

function LoginButtonShortcode( $args ) {
		
		// Check if this user connected his/her account to Patreon
		
		$user = wp_get_current_user();
		$user_patreon_id = '';
		
		if ( $user AND isset( $user->ID ) ) {
			$user_patreon_id = get_user_meta( $user->ID, 'patreon_user_id', true );
		}

		if ( !is_user_logged_in() OR ( is_user_logged_in() AND $user_patreon_id == '' ) ) {
			return Patreon_Frontend::showPatreonLoginButton();
		}
		
	}

Code file location:

patreon-connect/patreon-connect/classes/patreon_frontend.php

Conclusion

Now that you’ve learned how to embed the Patreon WordPress Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *