Ultimate Addons for Contact Form 7 Shortcodes

Below, you’ll find a detailed guide on how to add the Ultimate Addons for Contact Form 7 Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Ultimate Addons for Contact Form 7 Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Ultimate Addons for Contact Form 7 Plugin and the shortcodes it provides:

Plugin Icon
Ultimate Addons for Contact Form 7

"Ultimate Addons for Contact Form 7 is a powerful WordPress plugin that enhances your site's contact forms with additional features and customization options, making interaction more user-friendly."

★★★★☆ (53) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 5.4
Included Shortcodes:
  • [UACF7_URL]
  • [UACF7_BLOGINFO]
  • [UACF7_POSTINFO]
  • [UACF7_USERINFO]
  • [UACF7_CUSTOM_FIELDS]

Ultimate Addons for Contact Form 7 [UACF7_URL] Shortcode

The Ultimate Addons for Contact Form 7 shortcode, ‘UACF7_URL’, retrieves the current page URL. This shortcode calls a PHP function which uses WordPress’s get_permalink() function. This function returns the URL of the current page, allowing users to easily share or reference the page.

Shortcode: [UACF7_URL]

Examples and Usage

Basic example – The utilization of the UACF7_URL shortcode to display the permalink of the current page.

[UACF7_URL /]

PHP Function Code

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

Shortcode line:

add_shortcode('UACF7_URL', 'UACF7_URL');

Shortcode PHP function:

function UACF7_URL($val){ 
        $data = get_permalink();
        return $data;
    }

Code file location:

ultimate-addons-for-contact-form-7/ultimate-addons-for-contact-form-7/addons/dynamic-text/inc/shortcode.php

Ultimate Addons for Contact Form 7 [UACF7_POSTINFO] Shortcode

The UACF7_POSTINFO shortcode from the Ultimate Addons for Contact Form 7 plugin retrieves various post information. It can fetch the post permalink, specific post attributes, or the post title.

Shortcode: [UACF7_POSTINFO]

Parameters

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

  • post_permalink – retrieves the unique URL of the current post
  • attr – retrieves any attribute of the current post
  • post_title – retrieves the title of the current post

Examples and Usage

Basic example – Display the current post’s permalink using the UACF7_POSTINFO shortcode.

[UACF7_POSTINFO attr="post_permalink" /]

Using this shortcode, the permalink of the current post will be retrieved and displayed. This is handy when you want to easily share or reference the current post’s URL within the content.

Advanced examples

Display the current post’s content using the UACF7_POSTINFO shortcode.

[UACF7_POSTINFO attr="post_content" /]

In this example, the shortcode is used to fetch and display the content of the current post. This can be useful when you want to display a snippet or preview of the post’s content within other sections of your website.

Display the current post’s title when no attribute is provided.

[UACF7_POSTINFO /]

When no attribute is provided, the shortcode defaults to displaying the title of the current post. This can be useful for creating dynamic headings or titles based on the post’s title.

PHP Function Code

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

Shortcode line:

add_shortcode('UACF7_POSTINFO', 'UACF7_POSTINFO');

Shortcode PHP function:

function UACF7_POSTINFO($val){ 
        global $post; 
        $data = '';
        if($val['attr'] == 'post_permalink'){
            $data = get_permalink($post->ID);
        }elseif(!empty($val['attr'])){ 
            $post_attr = $val['attr'];
            $data =  $post->$post_attr;
        }else{
            $data = $post->post_title;
        }
        return $data;
    }

Code file location:

ultimate-addons-for-contact-form-7/ultimate-addons-for-contact-form-7/addons/dynamic-text/inc/shortcode.php

Ultimate Addons for Contact Form 7 [UACF7_USERINFO] Shortcode

The Ultimate Addons for Contact Form 7 shortcode, ‘UACF7_USERINFO’, retrieves user information. If a user is logged in, it fetches the specified attribute. If no attribute is specified, it defaults to the user’s nicename.

Shortcode: [UACF7_USERINFO]

Examples and Usage

Basic example – A simple usage of the UACF7_USERINFO shortcode. This will display the ‘user_nicename’ of the currently logged in user. If no user is logged in, it will return an empty string.

[UACF7_USERINFO /]

Advanced examples

Using the UACF7_USERINFO shortcode to display the ‘user_email’ of the currently logged in user. If no user is logged in, it will return an empty string. The ‘attr’ attribute is used to specify the user attribute to be displayed.

[UACF7_USERINFO attr="user_email" /]

Using the UACF7_USERINFO shortcode to display the ‘display_name’ of the currently logged in user. If no user is logged in, it will return an empty string. The ‘attr’ attribute is used to specify the user attribute to be displayed.

[UACF7_USERINFO attr="display_name" /]

Please note that the ‘attr’ attribute should match the exact attribute name in the WordPress user object. If the attribute does not exist or is empty, the shortcode will return an empty string.

PHP Function Code

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

Shortcode line:

add_shortcode('UACF7_USERINFO', 'UACF7_USERINFO');

Shortcode PHP function:

function UACF7_USERINFO($val){  
        $data = '';
        if( is_user_logged_in() ) {
            $current_user = wp_get_current_user();
            if(!empty($val['attr'])){
                $user_attr = $val['attr'];
                $data = $current_user->$user_attr;
            }else{
                $data = $current_user->user_nicename;
            } 
        }
        return $data;
    }

Code file location:

ultimate-addons-for-contact-form-7/ultimate-addons-for-contact-form-7/addons/dynamic-text/inc/shortcode.php

Ultimate Addons for Contact Form 7 [UACF7_CUSTOM_FIELDS] Shortcode

The Ultimate Addons for Contact Form 7 shortcode is a custom function that retrieves specific post metadata. This shortcode accepts an ID and a custom field name as parameters. If the ID is valid, it fetches the value of the specified custom field from the post metadata. It then returns this value, allowing you to display custom field data within your forms.

Shortcode: [UACF7_CUSTOM_FIELDS]

Parameters

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

  • id – unique identifier of the contact form
  • custom_fields – specific attributes or data of the contact form

Examples and Usage

Basic example – A simple usage of the shortcode to retrieve a custom field from a post by its ID.

[UACF7_CUSTOM_FIELDS attr="123/custom_field_name"]

Here, ‘123’ is the ID of the post and ‘custom_field_name’ is the name of the custom field you want to retrieve.

Advanced examples

Using the shortcode to retrieve multiple custom fields from a post by its ID. You can specify multiple custom fields separated by commas.

[UACF7_CUSTOM_FIELDS attr="123/custom_field_name1,custom_field_name2"]

In this example, ‘123’ is the ID of the post and ‘custom_field_name1,custom_field_name2’ are the names of the custom fields you want to retrieve. The values of these fields will be returned as a comma-separated string.

Using the shortcode to retrieve a custom field from multiple posts. You can specify multiple post IDs separated by commas.

[UACF7_CUSTOM_FIELDS attr="123,456/custom_field_name"]

In this example, ‘123,456’ are the IDs of the posts and ‘custom_field_name’ is the name of the custom field you want to retrieve. The values of the custom field from each post will be returned as a comma-separated string.

PHP Function Code

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

Shortcode line:

add_shortcode('UACF7_CUSTOM_FIELDS', 'UACF7_CUSTOM_FIELDS');

Shortcode PHP function:

function UACF7_CUSTOM_FIELDS($val){    
        $data ='';
        $value = explode("/",$val['attr']); 
        $id = $value[0];
        $custom_fields = $value[1];
        $data = '';
        if($id > 0){
            $data = get_post_meta($id, $custom_fields, true);
        }
        return $data;
    }

Code file location:

ultimate-addons-for-contact-form-7/ultimate-addons-for-contact-form-7/addons/dynamic-text/inc/shortcode.php

Conclusion

Now that you’ve learned how to embed the Ultimate Addons for Contact Form 7 Plugin shortcodes, 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 *