1

I am creating a simple db for School Students and want to achieve it in wordpress using any method that is available now.

Every student details like first name, class etc will be saved in database along with ID as primary key.

In PHP, there used to be ONE file like details.php etc and based on QUery passed using GET or POST method, it will display the details. Can we do the same in Wordpress using a SINGLE Page or Post;

Instead of creating seperate Page / Post for every student, i had created PHP Queries in Page / Post using WP Plugin which will display the details of student based on querying ID.

But i am not sure how to make it generalized so that on entering http://mywpsite.com/studentpageorpost/?id=10 i should get the details of student with ID 10; and on entering http://mywpsite.com/studentpageorpost/?id=11, i should get the details of ID 11;

Can anyone please help on this.

1
  • Why do you want to use wordpress to do this? Commented May 3, 2014 at 23:54

1 Answer 1

3

If I understand well the code would work like this:
1 Take the id number from url and stored
1.1 htmlspecialchars() is for converting html tags so you can't be hacked by php injection

$id = htmlspecialchars( $_GET["id"] );

2 Here we have stored the user info in a object with the wordpress function get_userdata();
2.1 If ID not found return false.

$user_data = get_userdata( $id ); 

Accessing Usermeta Data

$user_data = get_userdata( $id );
      echo $user_data->last_name .  ", " . $user_info->first_name . "\n";

Results in:

Doe, John

If you want to know how to access more user info use print_r($user_data); and will output all the info that the user has.

Here are some of the useful values in the wp_users and wp_usermeta tables you can access with this function for use in your theme or plugin:

  • users
    • ID
    • user_login
    • user_pass
    • user_nicename
    • user_email
    • user_url
    • user_registered
    • display_name

  • user_meta
    • user_firstname
    • user_lastname
    • nickname
    • description
    • wp_capabilities (array)
    • admin_color (Theme of your admin page. Default is fresh.)
    • closedpostboxes_page
    • primary_blog
    • rich_editing
    • source_domain

Edit: I think the above system is the easiest still as MarkBlythe sed, no need for individual account, you can use custom post type plugin and custom fields. You could add the students very fast in a loop and array with this function wp_create_user( $username, $password, $email );

Sign up to request clarification or add additional context in comments.

2 Comments

This assumes OP is going to add all students as individual WordPress users which may be overkill as based on the question they don't need individual accounts.
Thanks Francisc adn MarkBlythe, it solved my issue. I will give it a try

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.