Erp Shortcode

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

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

Plugin Icon
WP ERP | Complete HR solution with recruitment & job listings | WooCommerce CRM & Accounting

"WP ERP is a comprehensive HR solution plugin. It simplifies recruitment, job listings, and integrates perfectly with WooCommerce for seamless CRM and accounting operations."

★★★★✩ (136) Active Installs: 8000+ Tested with: 6.3.2 PHP Version: 7.2
Included Shortcodes:
  • [erp_subscription_form]

Erp [erp_subscription_form] Shortcode

The ‘erp_subscription_form’ shortcode is utilized in WordPress to generate a subscription form. It accepts a range of attributes, allowing customization of the form’s fields, labels, and placeholders. This shortcode checks if attributes are set, if not, it sets default values. It supports placeholders for email, first name, last name, and full name fields. The output is a subscription form, which is returned as a string using output buffering.

Shortcode: [erp_subscription_form]

Parameters

Here is a list of all possible erp_subscription_form shortcode parameters and attributes:

  • group – Specifies the group the contact belongs to
  • life_stage – Defines the life stage of the contact
  • button_lbl – Sets the label for the subscribe button
  • email_lbl – Sets the label for the email input field
  • extra_arg – Allows for additional arguments or parameters
  • email_placeholder – Defines placeholder text for email input field
  • first_name_placeholder – Sets placeholder text for first name field
  • last_name_placeholder – Sets placeholder text for last name field
  • full_name_placeholder – Sets placeholder text for full name field
  • first_name_lbl – Defines the label for the first name input field
  • last_name_lbl – Defines the label for the last name input field
  • full_name_lbl – Defines the label for the full name input field

Examples and Usage

Basic example – Display a subscription form with default settings

[erp_subscription_form /]

Advanced examples

Display a subscription form for a specific group with a custom button label and email label

[erp_subscription_form group="newsletter" button="Join us" email="Your email address" /]

Using the shortcode to display a subscription form with custom placeholders for email, first name, and last name fields

[erp_subscription_form email_placeholder="Enter your email" first_name_placeholder="Enter your first name" last_name_placeholder="Enter your last name" /]

Using the shortcode to display a subscription form with custom labels for first name, last name, and full name fields

[erp_subscription_form first_name="Your First Name" last_name="Your Last Name" full_name="Your Full Name" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'erp_subscription_form', [ $this, 'shortcode' ] );

Shortcode PHP function:

function shortcode( $attrs ) {
        if ( empty( $attrs ) ) {
            $attrs = [];
        }

        $args = [
            'group'      => isset( $attrs['group'] ) ? $attrs['group'] : null,
            'life_stage' => isset( $attrs['life_stage'] ) ? $attrs['life_stage'] : null,
            'button_lbl' => isset( $attrs['button'] ) ? $attrs['button'] : __( 'Subscribe', 'erp' ),
            'email_lbl'  => isset( $attrs['email'] ) ? $attrs['email'] : __( 'Email', 'erp' ),
            'extra_arg'  => isset( $attrs['extra_arg'] ) ? $attrs['extra_arg'] : null,
            //placeholder support
            'email_placeholder'      => isset( $attrs['email_placeholder'] ) ? $attrs['email_placeholder'] : '',
            'first_name_placeholder' => isset( $attrs['first_name_placeholder'] ) ? $attrs['first_name_placeholder'] : '',
            'last_name_placeholder'  => isset( $attrs['last_name_placeholder'] ) ? $attrs['last_name_placeholder'] : '',
            'full_name_placeholder'  => isset( $attrs['full_name_placeholder'] ) ? $attrs['full_name_placeholder'] : '',
        ];

        if ( ! empty( $attrs['first_name'] ) ) {
            $args['first_name_lbl'] = $attrs['first_name'];
        } elseif ( in_array( 'first_name', $attrs ) ) {
            $args['first_name_lbl'] = __( 'First Name', 'erp' );
        }

        if ( ! empty( $attrs['last_name'] ) ) {
            $args['last_name_lbl'] = $attrs['last_name'];
        } elseif ( in_array( 'last_name', $attrs ) ) {
            $args['last_name_lbl'] = __( 'Last Name', 'erp' );
        }

        if ( ! empty( $attrs['full_name'] ) ) {
            $args['full_name_lbl'] = $attrs['full_name'];
        } elseif ( in_array( 'full_name', $attrs ) ) {
            $args['full_name_lbl'] = __( 'Full Name', 'erp' );
        }

        ob_start();
        $this->subscription_form( $args );

        return ob_get_clean();
    }

Code file location:

erp/erp/modules/crm/includes/Subscription.php

Conclusion

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