• Resolved LNN

    (@ewan-norman)


    Hello,

    I am trying to get the current post tags in order to make a condition in the email notification.

    I tried: {embed_post.post_tags}, {embed_post.post_tag}, {embed_post.the_tags}, {embed_post.tags}… Couldn’t make them work.

    Can you please help.

    Thanks

    • This topic was modified 1 year, 9 months ago by LNN. Reason: Typo
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Tahmid ul Karim

    (@tahmidulkarim)

    Hello @ewan-norman,

    There isn’t any shortcodes to get the current post tags. The shortcodes that you have tried won’t work.

    You can try creating your own smartcodes in FluentForms using custom PHP codes. So, using custom codes you can fetch the post tags. Check our developer documentation here: https://fluentforms.com/docs/creating-custom-smartcode-for-form-editor/

    Thank you!

    Thread Starter LNN

    (@ewan-norman)

    Hello @tahmidulkarim

    That was very helpful; thank you very much. I was able to edit the snippets from the documentation to get the current embed post tags. Here is the code if anyone wants to achieve the same or if you have a better idea to make it cleaner:

    add_filter('fluentform_editor_shortcodes', function ($smartCodes) {
        $smartCodes[0]['shortcodes']['{ffc_current_tags}'] = 'Current Post Tags';
        return $smartCodes;
    });
    
    add_filter('fluentform_all_editor_shortcodes',function($data){
    	
    	$customShortCodes = [
    		     'title'=>'Current Tags',
                         'shortcodes' => ['{ffc_current_tags}' => 'ffc_current_tags',]
    		];
    	$data[] = $customShortCodes;
    	return $data;
    	
    },10,1);
    
    /*
     * To replace dynamic new smartcode the filter hook will be
     * fluentform_editor_shortcode_callback_{your_smart_code_name}
     */
    add_filter('fluentform_editor_shortcode_callback_ffc_current_tags', function ($value, $form) {
        $postTags = get_the_tags();
        $dynamicValue = '';
        if ($postTags) {
            foreach ($postTags as $tag) {
                $dynamicValue .= $tag->name . ', ';
            }
            $dynamicValue = rtrim($dynamicValue, ', ');
        } else {
            $dynamicValue = 'No tags found';
        }
        return $dynamicValue;
    }, 10, 2);

    Best regards!

    Plugin Support Tahmid ul Karim

    (@tahmidulkarim)

    Hi @ewan-norman,

    Thank you for sharing the code here! It looks good to me.

    Regards,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get the embed post tags’ is closed to new replies.