WordPress.org

Ready to get started?Download WordPress

Forums

Adding some sort of if-then statement in posts? (3 posts)

  1. ned4spd8874
    Member
    Posted 1 year ago #

    This is kind of a weird question, but it would be awesome if I could make it work!

    I present videos on my site. I would like to be able to display ad supported videos for non-members/subscribers and no ad-infused videos for members/subscribers. I use JW Player for video. I can create two separate players; one with ads, one without.

    But the kicker is how to present the right player to the right user?

    Any ideas out there?

  2. Rebecca Schaefer
    Member
    Posted 1 year ago #

    I'd use custom fields and shortcodes for this.

    Use a custom shortcode to embed where you'd want the video to be. In that shortcode, determine if the user is a member or not. Store the videos in their own custom fields ('ads', 'noads' maybe?). Once you've figured out what you're showing, just use do_shortcode to execute the video players default shortcode.

    add_shortcode('membershipVideo', 'executeMemberVideo');
    function executeMembershipVideo($args) {
        if(is_user_logged_in()) {
           // retrieve the custom field and call the player for that video
           return;
        }
        // retrieve the custom field for non-members/call the player.
        return;
    }
  3. ned4spd8874
    Member
    Posted 1 year ago #

    Thanks for the help! I'll have to look into that!

Topic Closed

This topic has been closed to new replies.

About this Topic