php – Shortcode in Shortcode/HTML Graphics and Pictures

Question

I got some problem regarding a shortcode in another shortcode. Here the whole PHP code snippet for the Outer shortcode:

function shortStat($atts, $content = NULL){

            if(isset($_POST['passeingabe'])){

            global $wpdb;
            
            $werte = shortcode_atts(array('status' => ''),$atts);

            $pwEingabe = $_POST['passeingabe'];
            $wpdb->eb_personen = "{$wpdb->prefix}eb_personen";
                
                $selStat = $wpdb->prepare("SELECT stat_".$werte['status']." FROM $wpdb->eb_personen 
                WHERE Passwort = %s AND fkVer_id = (SELECT ver_id from $wpdb->eb_veranstaltung 
                WHERE VeranstaltungName = %s);", stripslashes($pwEingabe), basename($_SERVER['REQUEST_URI']));
                $ergSelStat = $wpdb->get_results($selStat, ARRAY_A);
                $selPass = $wpdb->prepare("SELECT Passwort FROM $wpdb->eb_personen WHERE Passwort = %s;", stripslashes($pwEingabe));
                $ergSelPass = $wpdb->get_results($selStat, ARRAY_N);            
                        
                        if($wpdb->num_rows == 1){
                            
                            return do_shortcode($content);
                            
                        }else{
                            return "";
                        }

            }else{
                    echo '';
                }
        }

The outer shortcode checks if a customer has a certain status (Ranging from 1 to 9). If that customer got that status, then the inner shortcode will be executed. That shortcode displays a certain voucher code for that status. If the customer hasn’t got such a status then nothing shall be displayed. The shortcode and HTML structure looks like [Outer shortcode]HTML(Picture)[Inner Shortcode][/Outer shortcode].

My problem is, even if the customer doesn’t have the status(As checked in “if($wpdb->num_rows == 1) the HTML graphics or pictures are still displayed, even though without a voucher code. What do I have to write in “else” to avoid HTML graphics and pictures from being displayed?

And yeah I know, some words in the PHP code snippet are in German, but I hope that’s no problem.

0
Artok Kotra 1 month 2021-08-13T15:13:16-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse