Support » Plugin: YOP Poll » Create new poll – Hide options

  • Resolved Piani


    I have a member site with an admin that have set the standard option. All members can create new polls when ever they like.

    But I want to hide some options on the “Add New Yop Poll” page. I see the options in “admin.php”. But I can not just remove them since the page function requires the information to create a new poll.

    – I want all members to be able to edit “Results Display:” options.
    – But I want to hide the option below “Poll Answer Result Label:” (And only use the defalt I have set in options with the admin)

    The code is:

    <?php _e( 'Poll Answer Result Label', 'yop_poll' ); ?>:
    <td><input id="yop-poll-answer-result-label" type="text"
    value="<?php echo esc_html( stripslashes( $default_options['answer_result_label'] ) ); ?>"/>
    <small><i><?php _e( 'Use %POLL-ANSWER-RESULT-PERCENTAGES% for showing answer percentages and  %POLL-ANSWER-RESULT-VOTES% for showing answer number of votes', 'yop_poll' ); ?></i></small>

    The code starts with <tr> and ends with </tr>. Is there a user setting to hide this part or can I use some PhP hide code on this part? Hide but still set the default value hidden non visible on this page.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author YOP


    Hi wm,

    Edit inc/admin.php and in view_add_edit_new_poll() function add

    $poll_answer_result_label = isset( $default_options['answer_result_label']) ? $default_options['answer_result_label'] : "";


    if ( 'edit' == $action ){

    Also, after the if( ‘edit’ == $action ){ section add

    $default_options['answer_result_label'] = $poll_answer_result_label;

    so in the end you’ll have

    $default_options = get_option( 'yop_poll_options', array() );
                $poll_answer_result_label = isset( $default_options['answer_result_label']) ? $default_options['answer_result_label'] : "";
       if ( 'edit' == $action ){
        $poll_id     = ( isset ( $_GET ['id'] ) ? intval( $_GET ['id'] ) : 0 );
        $poll_author = Yop_Poll_Model::get_poll_field_from_database_by_id( 'poll_author', $poll_id );
        if ( ( !$this->current_user_can( 'edit_own_polls' ) || $poll_author != $current_user->ID ) && ( !$this->current_user_can( 'edit_polls' ) ) )
         wp_die( __( 'You are not allowed to edit this item.', 'yop_poll' ) );
        $yop_poll_model       = new Yop_Poll_Model ( $poll_id );
        $answers              = Yop_Poll_Model::get_poll_answers( $poll_id );
        $other_answer         = Yop_Poll_Model::get_poll_answers( $poll_id, array( 'other' ) );
        $custom_fields        = Yop_Poll_Model::get_poll_customfields( $poll_id );
        $page_name            = __( 'Edit Poll', 'yop_poll' );
        $action_type          = 'edit';
        $poll_default_options = get_yop_poll_meta( $poll_id, 'options', true );
        foreach ( $default_options as $option_name => $option_value ) {
         if ( isset ( $poll_default_options [$option_name] ) ){
          $default_options [$option_name] = $poll_default_options [$option_name];
                $default_options['answer_result_label'] = $poll_answer_result_label;

    In the code you pasted, set the <tr> tag as <tr style=’display: none’>
    This way it will not be displayed and each time you save the poll it will have the current value set in the general options.


    YOP Team



    Thanks alot for a fast and easy to understand instructon. This code solved my issue exactly as I wanted.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Create new poll – Hide options’ is closed to new replies.