0

I need to modify the Frames Video Player plugin slightly. https://wordpress.org/plugins/frames-video-gallery/

I'd like the playlists it displays to be for the currently logged in user only.

I think the simplest way to achieve this would be to alter the SQL query in the following file: frames-video-gallery/engine/api.php

Here is the function as it's currently written in the file:

function getPlaylists(){
                $fields = $this->getFields('playlist');
                $lists = $this->db->query( 'SELECT oid,'. $fields['cols'] .' FROM '.$this->table->playlists,  $fields);
        return $lists;
    }

So currently it's returning all playlists for all users.

Here is my attempted modification:

function getPlaylists(){
                $current_user = wp_get_current_user();
                $fields = $this->getFields('playlist');
                $lists = $this->db->query( 'SELECT oid,'. $fields['cols'] .' FROM '.$this->table->playlists,  $fields WHERE wp_users.ID='$current_user->ID');
        return $lists;
    }

I'm getting PHP errors though regarding my SQL syntax. I'm not familiar with the concatenation the author used in the SQL query. Any suggestions? Am I just missing a couple of quotations?

Thanks!

0

Yes, I think your quotes after the WHERE are backwards. Try it like this:

...$fields.' WHERE wp_users.ID='.$current_user->ID );

The "WHERE wp_users.ID=" part is plain text that is intended to be part of the query, so it needs to be in quotes. The $current_user->ID is a variable that should live outside the quotes.

If that doesn't work, I would suggest using a variable to store the SQL query and then output it as debugging. That way you can see what is being formed and see if it is what you expect.

This is how I do it:

$sql = db->prepare( "SELECT * FROM $table WHERE user=%s", $current_user->ID );

Hope this helps!

BTW, it took me awhile to get used to using a period as a concatenation operator.

  • Scott, Thanks for your help. I still haven't quite got the answer, but I appreciate the $sql testing suggestion. I also got a response from the plugin author. He's gone for a couple of days, but says he has a simple solution to for what I'm needing. – Brad Votava Mar 9 '17 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.