• I currently pull in ID’s from Airtable which is the exact same as the username of the user, example:

    Name: Jon Doe
    Wordpress Username: jdoe
    ID in Airtable: jdoe

    I currently am using a virtual post to create a dashboard for the user.

    I was wondering if there is a way to create a conditional logic or anyone knows of a plugin that would essentially check to see if the logged in user equals the [apr field=”ID”] before showing the contents of the page.

    Idea:
    –IF
    [apr field=”ID”] = current_user_username
    –THEN
    Show page content
    –ELSE
    “You do not have permission to view this page”

    Thank you so much to anyone you help me answer this quetion

    • This topic was modified 5 years, 7 months ago by moochie.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Great question @moochie . I’m looking for the same thing.

    Wondering if https://auth0.com/wordpress could be a help as it has a really powerful API for potential integration.

    This would be great, any word on this working? Did anyone find a solution?

    Thread Starter moochie

    (@moochie)

    @tobymurdock @patrickhilly I actually found a solution using PHP to achieve this.

    function user_name($atts, $content) {
         global $current_user;
         get_currentuserinfo();
         $username = current_user->user_login;
         
         $query = new AirpressQuery();
         $query->setConfig(“YOUR CONNECTION NAME”);
         $query->table(“YOUR TABLE NAME”);
         $query->filterByFormula(‘{ID}=“‘ . username . ‘“‘;
         
         $user_info = new AirpressCollection($query);
    
         foreach($user_info as $e){
              if($e[“User Subscription Level”] > 3){
                  echo $e[“Content”];
              } else {
                  echo ‘You do not have permission to view’;
    }
          };
    }
    
    add shortcode(‘user_content’, ‘user_name’);

    This example checks if the current logged in username in WordPress is equal to the ID inside Airtable, then it checks to see if the User Subscription Level is above 3 in Airtable for that particular user, then creates a shortcode ([user_content]) to be used. If all is true the shortcode shows the content in the “Content” column of Airtable if it’s not, it’ll show that you do not have permission.

    Foreach is not necessary btw. I just used in my example.

    I threw this together but that’s the idea and if @chetmac has a better solution or a problem with my example I’d love the feedback or more info

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Restrict Page based on User (ID)’ is closed to new replies.