• Resolved orbifold

    (@orbifold)


    I would like to create polls where only registered users with specific roles can vote

    I would also like to be able to do the following: allow users to vote at some poll only if they have voted at some other poll and the answer was of some given type

    Is it possible to do these things?

    https://www.ads-software.com/plugins/yop-poll/

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

    (@yourownprogrammer)

    Hi orbifold,

    To do that edit yop_poll_model.php and in register_vote, after

    $facebook_user_details = json_decode( self::base64_decode( $request['facebook_user_details'] ), true );

    add

    $ids       =array("id1","id2","id3");
                    $roles     =array("rol1","rol2");
                   if('wordpress'==$vote_type){
                       $user = new WP_User( $current_user->ID);
                    if(in_array($poll_id,$ids)){
                        if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
                            foreach ( $user->roles as $role )
                            if( in_array($role,$roles)){
                                continue;
    
                        }
                            else{
                                $this->error = __( 'You Don't Have Permission to Vote!', 'yop_poll' );
                                return false;
                            }
    
                        }
                        else{
                            $this->error = __( 'You Don't Have Permission to Vote!', 'yop_poll' );
                            return false;
                        }
                    }
                   }

    In $ids add the ID of the polls you want affected by these changes and in $roles you can specify the roles for your users.

    Let us know if you need more help.

    Thread Starter orbifold

    (@orbifold)

    Thanks a lot. I am having some problems to make these instructions work (apart from the ‘You Don’t… which is easy to correct). A user with the right role cannot vote

    However, I was thinking of adding user roles to vote permissions

    when you edit the poll, under “Other options – vote permissions” instead of having just guest, registered user and both, have a list of user roles and choose who can vote the poll and who cannot

    I plan to create new user roles especially for this, and let users choose which group they want to join, then restrict vote inside the group

    Plugin Author YOP

    (@yourownprogrammer)

    Hi orbifold,

    In $ids you can include the id of the polls you want, for example
    $ids=array(1,2,3,4); and in $roles you can set, for example $roles=array(“administrator”,”subscriber”).

    We have taken your suggestions into consideration and we will try to implement them in the future.

    Regards,

    YOP Team

    Thread Starter orbifold

    (@orbifold)

    Hello, thanks again. I found what was originating the errors I kept getting. I had a plugin called bbpress which was messing up all user roles. I removed it and now everything is fine (I am presently working on a simulated site created with Xampp)

    Thanks for considering this line of modifications for the future. It is particularly useful when you want to create a social network where users can form groups based on their ideas, for example political views on something: they would like to make polls within the same group. In general it is useful to refine any kind of polls and maybe useful in targeted advertising. Think of asking specific questions on something only to the people who have a specific opinion on something else. With a few combined questions you can easily get to the key point

    I think that with some patience I will succeed in modifying your code by myself to reach the goal I just described, but not immediately, because it is quite involved for my present knowledge of php

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘More options for vote permissions’ is closed to new replies.