Pmpro Buddypress Shortcode

Below, you’ll find a detailed guide on how to add the Pmpro Buddypress 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 Pmpro Buddypress Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Pmpro Buddypress Plugin and the shortcodes it provides:

Plugin Icon
BuddyPress & BuddyBoss Private Community with PMPro – Restrict Profiles, Groups, Messaging, Forum Discussions

"BuddyPress & BuddyBoss Private Community with PMPro is a plugin that enhances user privacy. It restricts profile access, groups, messaging, and forum discussions for a more exclusive community experience."

★★★✩✩ (8) Active Installs: 5000+ Tested with: 6.2.3 PHP Version: 7.0
Included Shortcodes:
  • [pmpro_buddypress_restricted]

Pmpro Buddypress [pmpro_buddypress_restricted] Shortcode

The ‘pmpro_buddypress_restricted’ shortcode is a feature of the PMPro-BuddyPress plugin. It displays a restriction message for certain content. This shortcode triggers the ‘pmpro_bp_restricted_message’ function which returns a message stating, “This content is restricted”. It’s a handy tool for managing access to content.

Shortcode: [pmpro_buddypress_restricted]

Examples and Usage

Basic example – Show a restricted message using the shortcode.

[pmpro_buddypress_restricted /]

The above shortcode will display the message “This content is restricted.” whenever it is used in a post or page. This is useful for informing users that they need to be a member to view certain content.

Advanced examples

Although the given shortcode does not support additional parameters, we can modify the function to accept parameters for a custom message and text domain.

Here is how you can modify the function:


function pmpro_bp_restricted_message($atts) {
    $atts = shortcode_atts( array(
        'message' => 'This content is restricted.',
        'text_domain' => 'pmpro-buddypress'
    ), $atts );

    return __($atts['message'], $atts['text_domain'] ) . ' ';
}
add_shortcode( 'pmpro_buddypress_restricted', 'pmpro_bp_restricted_message' );

After modifying the function, you can now use the shortcode with additional parameters as shown below:

[pmpro_buddypress_restricted message="This section is for members only." text_domain="my-text-domain" /]

This shortcode will display the message “This section is for members only.” with the text domain set to “my-text-domain”. This allows for greater flexibility in adjusting the message and text domain as needed.

PHP Function Code

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

Shortcode line:

add_shortcode( 'pmpro_buddypress_restricted', 'pmpro_bp_restricted_message' );

Shortcode PHP function:

function pmpro_bp_restricted_message() {
	return __('This content is restricted.', 'pmpro-buddypress' ) . ' ';
}

Code file location:

pmpro-buddypress/pmpro-buddypress/includes/restrictions.php

Conclusion

Now that you’ve learned how to embed the Pmpro Buddypress 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 *