mardi 12 avril 2016

How to store the certification content into database on WPLMS - Wordpress

I'm trying to save the username, course taken and course teacher to a MySQL database when someone generates the certification, but I'm not being able to identify the variables used to generate those values.

Does anyone has the variables used by wplms?

As far as I can see, the variables are inside the_content() but I'm not able to expand it and see inside. If someone knows a way to check the content inside, please advice.

<?php
get_header(vibe_get_header());
if ( have_posts() ) : while ( have_posts() ) : the_post();

$print=get_post_meta($post->ID,'vibe_print',true);


$class=get_post_meta($post->ID,'vibe_custom_class',true);
$css=get_post_meta($post->ID,'vibe_custom_css',true);

$bgimg_id=get_post_meta($post->ID,'vibe_background_image',true);

$bgimg=wp_get_attachment_info( $bgimg_id );

$width = get_post_meta(get_the_ID(),'vibe_certificate_width',true);
$height = get_post_meta(get_the_ID(),'vibe_certificate_height',true);

do_action('wplms_certificate_before_full_content');
?>
<section id="certificate" <?php echo 'style="'.(is_numeric($width)?'width:'.$width.'px;':'').''.(is_numeric($height)?'height:'.$height.'px':'').'"'; ?>>
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <?php do_action('wplms_certificate_before_content'); ?>
                    <div class="extra_buttons">
                        <?php do_action('wplms_certificate_extra_buttons');
                        if(vibe_validate($print)){
                            echo '<a href="#" class="certificate_print"><i class="icon-printer-1"></i></a>';
                            echo '<a href="#" class="certificate_pdf"><i class="icon-file"></i></a>';
                        }
                        ?>
                    </div>
                    <div class="certificate_content <?php echo $class;?>" style="<?php
                            if(isset($bgimg_id) && $bgimg_id && isset($bgimg['src']))
                                echo 'background:url('.$bgimg['src'].');';
                        ?>" <?php 

                        if(is_numeric($width))
                            echo 'data-width="'.$width.'" ';

                        if(is_numeric($height))
                            echo 'data-height="'.$height.'" ';
                        ?>>
                        <?php echo (isset($css)?'<style>'.$css.'</style>':'');?>
                        <?php
                            the_content();
                        ?>
                         <?php do_action('wplms_certificate_after_content'); ?>
                    </div>
                </div>
                <?php

                endwhile;
                endif;
                ?>
            </div>
        </div>
    </div>
</section>
<?php

$servername = "localhost";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";

try {
  $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  // set the PDO error mode to exception
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  echo "Connected successfully";
  }
catch(PDOException $e)
  {
  echo "Connection failed: " . $e->getMessage();
  }

$stmt = $conn->prepare("INSERT INTO certificados (usuario, nome_professor, nome_curso) VALUES ('william', 'professor', 'curso')");
$stmt->execute();

do_action('wplms_certificate_after_full_content');

get_footer(vibe_get_footer());
?>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire