• Resolved Lepton85

    (@lepton85)


    Dear Matt,

    Thank you, the idea behind the plugin is excellent. It’s great, that in theory I can hide menu items based on the privileges of the logged in user. It works well, when the user is logged in. But I visit the site without logging in, this is what I get:

    Warning: Missing argument 2 for CTXPS_Security::get_term_protection(), called in /home/peteqvzr/public_html/elt/wp-content/plugins/contexture-page-security/core/CTXPS_Security.php on line 493 and defined in /home/peteqvzr/public_html/elt/wp-content/plugins/contexture-page-security/core/CTXPS_Security.php on line 456

    Could you please advise what the problem may be?
    Many thanks in advance,
    Peter

    PS. my site lives here: https://elt.peterfabri.co.uk — but I removed the menu item for now, don’t want visitors to be greeted with a massive PHP error.

    https://www.ads-software.com/plugins/contexture-page-security/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Lepton85, did you ever get this sorted? I have the same problem on my site.

    https://theroutiers.org

    Wayne

    I’ve found a work-around. Clear the Menu Filtering checkbox and force login by checking the Send anonymous users to login screen checkbox.

    Anonymous users can see the menu items, but when they click on them, they get the login screen instead.

    i edited the file:
    CTXPS_Security.phh

    look for the line containing the function definition start:
    public static function get_term_protection($term_id,$taxonomy){

    replace this function by:

    public static function get_term_protection($term_id,$taxonomy){
            //If this branch isn't protected, just stop now and save all that processing power
            if (!CTXPS_Queries::check_term_protection($term_id,$taxonomy)){
                return false;
            }
    
            //If we're still going, then it means something above us is protected, so lets get the list of permissions
            global $wpdb;
            $return = array();
            $group_array = array();
            /**Gets the parent id of the current page/post*/
            $parent_id = get_term($term_id,$taxonomy);
            $parent_id = (integer)$parent_id->parent;
            /**Gets the ctx_ps_security data for this post (if it exists) - used to determine if this is the topmost secured page*/
            //$amisecure = get_post_meta($postid,'ctx_ps_security',true);
    
            //1. If I am secure, get my groups
            //if(!empty($amisecure)){
                //Get Group relationship info for this page from wp_ps_security, join wp_posts on postid
                $groups = CTXPS_Queries::get_groups_by_object('term',$term_id, true);
    
                //If 0 results, dont do anything. Otherwise...
                if(!empty($groups)){
                    foreach($groups as $group){
                        $group_array[$group->group_id] = $group->group_title;
                    }unset($group);
                }
            //}
            //Add an item to the array. 'pageid'=>array('groupid','groupname')
            $return[(string)$term_id] = $group_array;
            unset($group_array);
            //2. If I have a parent, recurse
                //Using our earlier results, check post_parent. If it's != 0 then recurse this function, adding the return value to $array
                if($parent_id != 0){
                    //$recursedArray = CTXPS_Security::get_protection($parentid);
                    //$array = array_merge($array,$recursedArray);
                    $parent_array = self::get_term_protection($parent_id,$taxonomy);
                    if(!!$parent_array){
                      $return += $parent_array;
                    }
                }
    
            //3. Return the completed $array
            return $return;
        }

    and change line 362 into:
    return self::get_term_protection($content_id,$taxonomy);

    this removed the errors for me.

    the functionality of not showing the menu items of protected categories and posts still works so this looks like a good addition to the original files.

    That looks great, thank you. I’ll try it on my site.

    Plugin Author Dutch van Andel

    (@veraxus)

    Thank you tazitiz, I’ve incorporated your fix into the next update.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Protected menu item causes PHP error’ is closed to new replies.