0
votes

I'm building site based on wordpress for my client that requires album/gallery authentication. I've made custom plugin that stores galleries and images in custom tables in the database. Now i want to create a simple page for clients so they can sign in with gallery name and password to it and browse their galleries. I was thinking about making a page in wp admin and custom template for it and then handle authentication in there.

How would you do such authentication?

1
Why you don't try with a wp plugin that block just some content? And permit authentication.Jabel Márquez
Voting to close as too broad, there are too many possible answers (see help center) and they would be too long, basically a full blown plugin. Roadmap: 1) Use WP native user's system. 2) Find a plugin to handle users and privileges (there are few great and good) or code your own rules. 3) Create the interface (via theme template in the frontend or plugin page in the backend).brasofilo
one way can be to put your login code in shortcode via wordpress.org/plugins/shortcode-exec-php and create a gallery login page by creating a "new page" in wp-admin having login page design along with shortcode to handle login.Pranay Bhardwaj
I can't use native user system because it requires email for users. Each gallery have own login/password. Neo: I was thinking of something similiar and i think i'm gonna go that way.RlyDontKnow

1 Answers

0
votes

The basic approach is:

  1. register a function with the admin_menu event
  2. add your pages and sub-pages
  3. verify permissions

Read roles and capabilities in the Codex for details.

add_action('admin_menu', 'pluginprefix_admin_menu'); // 1

function pluginprefix_admin_menu() {
    //2
    $plugurl = plugin_dir_url( __FILE__ );
    /*
    add_menu_page( $page_title, $menu_title, $capability, $menu_slug,
                     $function, $icon_url, $position );

    add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
                        $menu_slug, $function );

    for example: */

    add_menu_page( 'Statistikk', 'Statistikk', 'edit_plugins',
                   'pluginprefix_main', 'pluginprefix_page_main',
                   "$plugurl/img/stats-menu.png", 25);

    add_submenu_page( 'pluginprefix_main', 'Statistikk - Instillinger',
                      'Instillinger', 'edit_plugins', 'pluginprefix_fields',
                      'pluginprefix_page_fields' );

function pluginprefix_page_main() {
    // 3
    if ( !current_user_can( 'manage_options' ) )  {
    wp_die( __( 'You do not have sufficient permissions to access this page.' ));
    }
    include( MY_TEMPLATES . 'settings_page.tpl.php' );

}

. . .

I see. In that case;

  1. create a form with login / password fields, and post it to "wp-ajax".
  2. on the other end, compare the login and password with the stored and salted hashes.
  3. and finally set a session variable indicating that the user can browse a certain album.