Viewing 1 replies (of 1 total)
  • Plugin Author sewpafly

    (@sewpafly)

    It’s possible, but you would probably have to do some coding and get your hands a little dirty…

    Example… I haven’t tested this

    In PTE code you’ll see this:

    /**
     * Perform the capability check
     *
     * @param $id References the post that the user needs to have permission to edit
     * @returns boolean true if the current user has permission else false
     */
    function pte_check_id( $id ) {
    	if ( !$post = get_post( $id ) ) {
    		return false;
    	}
    	if ( current_user_can( 'edit_post', $id )
    		|| current_user_can( 'pte-edit', $id ) )
    	{
    		return apply_filters( 'pte-capability-check', true, $id );
    	}
    	return apply_filters( 'pte-capability-check', false, $id );
    }

    If you want to give a user permission to use PTE, you have to give them the link to PTE (pte_url(<image_id>, true); Returns a url to an iframe with the PTE editor), and do your own user check:

    function check_user($current, $image_id) {
       $user = get_current_user();
       // change the isGood() check to your own logic
       return ( $user->isGood() ) ? true : false;
    }
    add_filter('pte-capability-check', 'check_user', 10, 2); // the 10 is only important as a placeholder, the 2 is needed so you get your image_id in the check_user function
Viewing 1 replies (of 1 total)
  • The topic ‘Can this be used on the frontend?’ is closed to new replies.