Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author xnau webdesign

    (@xnau)

    The standard practice for this is to place the code in the theme’s functions.php file.

    It can also be added as a plugin.

    Thread Starter kavg

    (@kavg)

    I’ve added a plugin to make a custom tag and successfully installed and activated it. But when I used it in a string combine field it does not display anything. The field stays empty.

    Here’s my code

    <?php
    /**
     * Plugin Name: PDb With Custom tags
     * Description: adds custom template tags to be used in string combine fields
     */
    
        add_filter( 'pdb-tag_template_data_before_replace', function ($tag_list) {
            $id = $tag_list['id'];
            if (strlen($id) == 1){
                $formattedID = "000" . $id;
            } elseif (strlen($id) == 2) {
                $formattedID = "00" . $id;
            } elseif (strlen($id) == 3) {
                $formattedID = "0" . $id;
            } else {
                $formattedID = $id;
            }
            $tag_list['member_id'] = substr($tag_list['batch'], -2) . $tag_list['university'] . $formattedID;
            return $tag_list;
        } );

    I believe my code works properly or is there anything wrong with it?

    Plugin Author xnau webdesign

    (@xnau)

    Generally, you’ll be on your own to debug custom code, this is not support I provide.

    However, the code looks ok, but you need to debug your code. You can probably use the plugin debugger for this. Add an error_log statement to your code so you can see if the tag is getting added to the tag array correctly. That will tell you if the plugin is running and if you’re successfully adding your tag.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Where should I add php code to create custom tags?’ is closed to new replies.