Problemas en la implementación de shortcode del plugin Groups en template de plugin en archivo .PHP

6 views
Skip to first unread message

HFVWEBDESIGN

unread,
Oct 20, 2017, 2:34:48 PM10/20/17
to Desarrolladores PHP Colombia
Hola amigos, recurro a ustedes porque estoy teniendo problemas en implementar un shortcode del plugin Groups, la finalidad del plugin es bloquear contenido para ser visible unicamente a usuarios pertenecientes a determinados grupos,  el sitio web hecho en wordpress, en que se esta utilizando es un portal de empleo y se requiere bloquear cierta información especifica de los curriculums de los candidatos (correo, telefono, etc.) a menos que ciertos usuarios hallan pagado para acceder a la información.

Para hacer esto tengo que implementar el código corto directamente en el template del plugin de portal de empleo que estamos utilizando.

La documentación del plugin Groups, indica de  manera muy básica como utilizar el código corto directamente en un template, ejemplo básico:

<?php
echo do_shortcode( '[groups_member group="Registered"]Hello member![/groups_member]' );
?>

o este otro método:

<h1><?php _e( 'Welcome', 'example' ); ?></h1>
<?php
$login_content 
= sprintf(
'[groups_non_member group="Registered"]<p>%s</p>[groups_login][/groups_non_member]',
__
( 'Please log in:', 'example' )
);
echo do_shortcode
( $login_content );
?>




He utilizado este método en algunas plantillas del plugin de portal de empleo y ha funcionado, como en el siguiente:

<div class="custom-field-wrapper">
     <span class="js-bold"><?php echo __('Email Address', 'js-jobs') . ':&nbsp;'; ?></span>
                                    
        <?php echo do_shortcode('[groups_member group="resume"]
        <span class="get-text">
        '.$myresume->email_address.'
        </span> 
        [/groups_member]');?>
                                    
</div>

Pero es problema es que no me esta funcionando al utilizarlo en la siguiente función, donde necesito eliminar un bloque completo de información, algo estoy haciendo mal

Aquí el código original que necesito ocultar en el template:

function getPersonalTopSection($owner, $resumeformview) {
        $adminLogin = current_user_can('manage_options');
        $html = '<div class="resume-top-section">';  //quiero ocultar toda la información de este div
        if (isset(jsjobs::$_data[2][1]['photo'])) {
            $html .= '<div class="js-col-lg-4">';
            if (jsjobs::$_data[0]['personal_section']->photo != '') {
                $wpdir = wp_upload_dir();
                $data_directory = JSJOBSincluder::getJSModel('configuration')->getConfigurationByConfigName('data_directory');
                $img = $wpdir['baseurl'] . '/' . $data_directory . '/data/jobseeker/resume_' . jsjobs::$_data[0]['personal_section']->id . '/photo/' . jsjobs::$_data[0]['personal_section']->photo;
            } else {
                $img = jsjobs::$_pluginpath . 'includes/images/users.png';
            }
            $html .= '<img src="' . $img . '" />';
            $html .= '</div>';
            $html .= '<div class="js-col-lg-8">';
        } else {
            $html .= '<div class="js-col-lg-12">';
        }
        if (isset(jsjobs::$_data[2][1]['first_name']) || isset(jsjobs::$_data[2][1]['middle_name']) || isset(jsjobs::$_data[2][1]['last_name'])) {
            $html .= '<span class="resume-tp-name">' . jsjobs::$_data[0]['personal_section']->first_name . ' ' . jsjobs::$_data[0]['personal_section']->middle_name . ' ' . jsjobs::$_data[0]['personal_section']->last_name;
            $layout = JSJOBSrequest::getVar('layout');
            $editsocialclass = '';
            // if ($resumeformview == 0 && ($layout == 'addresume' || $owner == 1)) {
            //     $html .= '<a class="personal_section_edit" href="#"><img src="' . jsjobs::$_pluginpath . 'includes/images/edit-resume.png" /></a>';
            //     $editsocialclass = 'editform';
            // }elseif($adminLogin || (!is_user_logged_in() && isset($_SESSION['wp-jsjobs']))) {
            //     $html .= '<a class="personal_section_edit" href="#"><img src="' . jsjobs::$_pluginpath . 'includes/images/edit-resume.png" /></a>';
            //     $editsocialclass = 'editform';
            // }
            $html .= '<div id="job-info-sociallink" class="' . $editsocialclass . '">';
            if (!empty(jsjobs::$_data[0]['personal_section']->facebook)) {
                if(strstr(jsjobs::$_data[0]['personal_section']->facebook, 'http') ){
                    $facebook = jsjobs::$_data[0]['personal_section']->facebook ;
                }else{
                    $facebook = 'http://'.jsjobs::$_data[0]['personal_section']->facebook;
                }
                $html .= '<a href="' . $facebook . '" target="_blank"><img src="' . jsjobs::$_pluginpath . 'includes/images/scround/fb.png"/></a>';
            }
            if (!empty(jsjobs::$_data[0]['personal_section']->twitter)) {
                if(strstr(jsjobs::$_data[0]['personal_section']->twitter, 'http') ){
                    $twitter = jsjobs::$_data[0]['personal_section']->twitter;
                }else{
                    $twitter = 'http://'.jsjobs::$_data[0]['personal_section']->twitter;
                }
                $html .= '<a href="' . $twitter . '" target="_blank"><img src="' . jsjobs::$_pluginpath . 'includes/images/scround/twitter.png"/></a>';
            }
            if (!empty(jsjobs::$_data[0]['personal_section']->googleplus)) {
                if(strstr(jsjobs::$_data[0]['personal_section']->googleplus, 'http') ){
                    $googleplus = jsjobs::$_data[0]['personal_section']->googleplus;
                }else{
                    $googleplus = 'http://'.jsjobs::$_data[0]['personal_section']->googleplus;
                }
                $html .= '<a href="' . $googleplus . '" target="_blank"><img src="' . jsjobs::$_pluginpath . 'includes/images/scround/gmail.png"/></a>';
            }
            if (!empty(jsjobs::$_data[0]['personal_section']->linkedin)) {
                if(strstr(jsjobs::$_data[0]['personal_section']->linkedin, 'http') ){
                    $linkedin = jsjobs::$_data[0]['personal_section']->linkedin;
                }else{
                    $linkedin = 'http://'.jsjobs::$_data[0]['personal_section']->linkedin;
                }
                $html .= '<a href="' . $linkedin . '" target="_blank"><img src="' . jsjobs::$_pluginpath . 'includes/images/scround/in.png"/></a>';
            }
            $html .= '</div>';

            $html .= '</span>';
        }
        if (isset(jsjobs::$_data[2][1]['application_title'])) {
            $html .= '<span class="resume-tp-apptitle">' . jsjobs::$_data[0]['personal_section']->application_title . '</span>';
        }
        if (jsjobs::$_data['resumecontactdetail'] == true || $adminLogin) {
            if (isset(jsjobs::$_data[2][1]['email_address'])) {
                $html .= '<span class="resume-tp-apptitle">' . jsjobs::$_data[0]['personal_section']->email_address . '</span>';
            }
        }
        $layout = JSJOBSrequest::getVar('jsjobslt');
        if ($layout != 'printresume') {
            if ($owner != 1) { // Current user is not owner and (Consider as employer)
                if (isset(jsjobs::$_data['coverletter']) && !empty(jsjobs::$_data['coverletter'])) {
                    // View cover letter icon 
                    $html .= '<a href="#" onclick="showPopupAndSetValues();"><img src="' . jsjobs::$_pluginpath . 'includes/images/resume/coverletter.png"/></a>';
                }
            }
            if (jsjobs::$_data['resumecontactdetail'] == true || $adminLogin) {
                $html .= '<a target="_blank" href="' . jsjobs::makeUrl(array('jsjobsme'=>'resume', 'jsjobslt'=>'pdf', 'jsjobsid'=>jsjobs::$_data[0]['personal_section']->id,'jsjobspageid'=>jsjobs::getPageid())) . '"><img src="' . jsjobs::$_pluginpath . '/includes/images/pdf.png" /></a>';
                $html .= '<a target="_blank" href="' . jsjobs::makeUrl(array('jsjobsme'=>'export', 'task'=>'exportresume', 'action'=>'jsjobtask', 'jsjobsid'=>jsjobs::$_data[0]['personal_section']->id,'jsjobspageid'=>jsjobs::getPageid())) . '"><img src="' . jsjobs::$_pluginpath . '/includes/images/export.png" /></a>';
            }
            $html .= '<a href="#" id="print-link" data-resumeid="' . jsjobs::$_data[0]['personal_section']->id . '" ><img src="' . jsjobs::$_pluginpath . '/includes/images/print.png" /></a>';
            if(!empty(jsjobs::$_data[0]['file_section']) && (jsjobs::$_data['resumecontactdetail'] == true || $adminLogin)){
                $html .= '<a class="downloadall" target="_blank" href="' . jsjobs::makeUrl(array('jsjobsme'=>'resume', 'action'=>'jsjobtask', 'task'=>'getallresumefiles', 'resumeid'=>jsjobs::$_data[0]['personal_section']->id, 'jsjobspageid'=>JSJOBSRequest::getVar('jsjobspageid'))) . '" ><img src="' . jsjobs::$_pluginpath . '/includes/images/download-all.png" />' . __('Resume files download', 'js-jobs') . '</a>';
            }
        } elseif ($layout == 'printresume') {
            $html .= '<a href="javascript:window.print();" class="grayBtn">' . __('Print', 'js-jobs') . '</a>';
        }

        $html .= '</div>'; // close for the inner section
        $html .= '</div>; // closing div of resume-top-section
        return $html;
    }


Aquí el código que estoy utilizando con el shortcode, pero que me oculta todo el curriculum y no la sección que quiero ocultar
function getPersonalTopSection($owner, $resumeformview) {
        $adminLogin = current_user_can('manage_options');
        $html = echo do_shortcode ('[groups_member group="resume"] <div class="resume-top-section">';  
        if (isset(jsjobs::$_data[2][1]['photo'])) {
            $html .= '<div class="js-col-lg-4">';
            if (jsjobs::$_data[0]['personal_section']->photo != '') {
                $wpdir = wp_upload_dir();
                $data_directory = JSJOBSincluder::getJSModel('configuration')->getConfigurationByConfigName('data_directory');
                $img = $wpdir['baseurl'] . '/' . $data_directory . '/data/jobseeker/resume_' . jsjobs::$_data[0]['personal_section']->id . '/photo/' . jsjobs::$_data[0]['personal_section']->photo;
            } else {
                $img = jsjobs::$_pluginpath . 'includes/images/users.png';
            }
            $html .= '<img src="' . $img . '" />';
            $html .= '</div>';
            $html .= '<div class="js-col-lg-8">';
        } else {
            $html .= '<div class="js-col-lg-12">';
        }
        if (isset(jsjobs::$_data[2][1]['first_name']) || isset(jsjobs::$_data[2][1]['middle_name']) || isset(jsjobs::$_data[2][1]['last_name'])) {
            $html .= '<span class="resume-tp-name">' . jsjobs::$_data[0]['personal_section']->first_name . ' ' . jsjobs::$_data[0]['personal_section']->middle_name . ' ' . jsjobs::$_data[0]['personal_section']->last_name;
            $layout = JSJOBSrequest::getVar('layout');
            $editsocialclass = '';
            // if ($resumeformview == 0 && ($layout == 'addresume' || $owner == 1)) {
            //     $html .= '<a class="personal_section_edit" href="#"><img src="' . jsjobs::$_pluginpath . 'includes/images/edit-resume.png" /></a>';
            //     $editsocialclass = 'editform';
            // }elseif($adminLogin || (!is_user_logged_in() && isset($_SESSION['wp-jsjobs']))) {
            //     $html .= '<a class="personal_section_edit" href="#"><img src="' . jsjobs::$_pluginpath . 'includes/images/edit-resume.png" /></a>';
            //     $editsocialclass = 'editform';
            // }
            $html .= '<div id="job-info-sociallink" class="' . $editsocialclass . '">';
            if (!empty(jsjobs::$_data[0]['personal_section']->facebook)) {
                if(strstr(jsjobs::$_data[0]['personal_section']->facebook, 'http') ){
                    $facebook = jsjobs::$_data[0]['personal_section']->facebook ;
                }else{
                    $facebook = 'http://'.jsjobs::$_data[0]['personal_section']->facebook;
                }
                $html .= '<a href="' . $facebook . '" target="_blank"><img src="' . jsjobs::$_pluginpath . 'includes/images/scround/fb.png"/></a>';
            }
            if (!empty(jsjobs::$_data[0]['personal_section']->twitter)) {
                if(strstr(jsjobs::$_data[0]['personal_section']->twitter, 'http') ){
                    $twitter = jsjobs::$_data[0]['personal_section']->twitter;
                }else{
                    $twitter = 'http://'.jsjobs::$_data[0]['personal_section']->twitter;
                }
                $html .= '<a href="' . $twitter . '" target="_blank"><img src="' . jsjobs::$_pluginpath . 'includes/images/scround/twitter.png"/></a>';
            }
            if (!empty(jsjobs::$_data[0]['personal_section']->googleplus)) {
                if(strstr(jsjobs::$_data[0]['personal_section']->googleplus, 'http') ){
                    $googleplus = jsjobs::$_data[0]['personal_section']->googleplus;
                }else{
                    $googleplus = 'http://'.jsjobs::$_data[0]['personal_section']->googleplus;
                }
                $html .= '<a href="' . $googleplus . '" target="_blank"><img src="' . jsjobs::$_pluginpath . 'includes/images/scround/gmail.png"/></a>';
            }
            if (!empty(jsjobs::$_data[0]['personal_section']->linkedin)) {
                if(strstr(jsjobs::$_data[0]['personal_section']->linkedin, 'http') ){
                    $linkedin = jsjobs::$_data[0]['personal_section']->linkedin;
                }else{
                    $linkedin = 'http://'.jsjobs::$_data[0]['personal_section']->linkedin;
                }
                $html .= '<a href="' . $linkedin . '" target="_blank"><img src="' . jsjobs::$_pluginpath . 'includes/images/scround/in.png"/></a>';
            }
            $html .= '</div>';

            $html .= '</span>';
        }
        if (isset(jsjobs::$_data[2][1]['application_title'])) {
            $html .= '<span class="resume-tp-apptitle">' . jsjobs::$_data[0]['personal_section']->application_title . '</span>';
        }
        if (jsjobs::$_data['resumecontactdetail'] == true || $adminLogin) {
            if (isset(jsjobs::$_data[2][1]['email_address'])) {
                $html .= '<span class="resume-tp-apptitle">' . jsjobs::$_data[0]['personal_section']->email_address . '</span>';
            }
        }
        $layout = JSJOBSrequest::getVar('jsjobslt');
        if ($layout != 'printresume') {
            if ($owner != 1) { // Current user is not owner and (Consider as employer)
                if (isset(jsjobs::$_data['coverletter']) && !empty(jsjobs::$_data['coverletter'])) {
                    // View cover letter icon 
                    $html .= '<a href="#" onclick="showPopupAndSetValues();"><img src="' . jsjobs::$_pluginpath . 'includes/images/resume/coverletter.png"/></a>';
                }
            }
            if (jsjobs::$_data['resumecontactdetail'] == true || $adminLogin) {
                $html .= '<a target="_blank" href="' . jsjobs::makeUrl(array('jsjobsme'=>'resume', 'jsjobslt'=>'pdf', 'jsjobsid'=>jsjobs::$_data[0]['personal_section']->id,'jsjobspageid'=>jsjobs::getPageid())) . '"><img src="' . jsjobs::$_pluginpath . '/includes/images/pdf.png" /></a>';
                $html .= '<a target="_blank" href="' . jsjobs::makeUrl(array('jsjobsme'=>'export', 'task'=>'exportresume', 'action'=>'jsjobtask', 'jsjobsid'=>jsjobs::$_data[0]['personal_section']->id,'jsjobspageid'=>jsjobs::getPageid())) . '"><img src="' . jsjobs::$_pluginpath . '/includes/images/export.png" /></a>';
            }
            $html .= '<a href="#" id="print-link" data-resumeid="' . jsjobs::$_data[0]['personal_section']->id . '" ><img src="' . jsjobs::$_pluginpath . '/includes/images/print.png" /></a>';
            if(!empty(jsjobs::$_data[0]['file_section']) && (jsjobs::$_data['resumecontactdetail'] == true || $adminLogin)){
                $html .= '<a class="downloadall" target="_blank" href="' . jsjobs::makeUrl(array('jsjobsme'=>'resume', 'action'=>'jsjobtask', 'task'=>'getallresumefiles', 'resumeid'=>jsjobs::$_data[0]['personal_section']->id, 'jsjobspageid'=>JSJOBSRequest::getVar('jsjobspageid'))) . '" ><img src="' . jsjobs::$_pluginpath . '/includes/images/download-all.png" />' . __('Resume files download', 'js-jobs') . '</a>';
            }
        } elseif ($layout == 'printresume') {
            $html .= '<a href="javascript:window.print();" class="grayBtn">' . __('Print', 'js-jobs') . '</a>';
        }

        $html .= '</div>'; // close for the inner section
        $html .= '</div>[/groups_member]'); // closing div of resume-top-section
        return $html;
    }

Al implementarlo no solo se oculta el div en rojo, que información de contacto, sino el resto de los campos del curriculum

Gracias amigos de antemano, saludos
Reply all
Reply to author
Forward
0 new messages