mslave
Forum Replies Created
-
Forum: Plugins
In reply to: [Improve My City] Create a mechanim to allow users see only their issuesedit this “imc-core-filter-func.php” in functions folder
find for this: Returns issues for user
and replace it whith this
/** * 13.07 * Returns issues for user * */ function imcLoadIssuesForUsers($paged, $page, $user_id, $status, $category){ $imported_sstatus = explode(",", $status); $imported_scategory = explode(",", $category); //the filtering is for users so -plus user's pending issues- $include_pending = true; if($imported_scategory && !$imported_sstatus) { $filter = imcFilterIssuesByCategory($imported_scategory,$include_pending); $pendingOfUser = get_posts(array( 'post_status' => 'pending', 'post_type' => 'imc_issues', 'author' => $user_id, 'posts_per_page' => -1, 'post__not_in' => $filter, )); $allPublish = get_posts(array( 'post_status' => 'publish', 'post_type' => 'imc_issues', 'author' => $user_id, 'posts_per_page' => -1, 'post__not_in' => $filter, )); }elseif(!$imported_scategory && $imported_sstatus){ $filter = imcFilterIssuesByStatus($imported_sstatus,$include_pending); $pendingOfUser = get_posts(array( 'post_status' => 'pending', 'post_type' => 'imc_issues', 'author' => $user_id, 'posts_per_page' => -1, 'post__not_in' => $filter, )); $allPublish = get_posts(array( 'post_status' => 'publish', 'post_type' => 'imc_issues', 'author' => $user_id, 'posts_per_page' => -1, 'post__not_in' => $filter, )); }elseif($imported_scategory && $imported_sstatus){ $filter1 = imcFilterIssuesByCategory($imported_scategory,$include_pending); $filter2 = imcFilterIssuesByStatus($imported_sstatus,$include_pending); $mergedfilters = array_merge($filter1, $filter2); //combine queries $uniqueposts_filters = array_unique($mergedfilters); //remove duplicate post ids $pendingOfUser = get_posts(array( 'post_status' => 'pending', 'post_type' => 'imc_issues', 'author' => $user_id, 'posts_per_page' => -1, 'post__not_in' => $uniqueposts_filters, )); $allPublish = get_posts(array( 'post_status' => 'publish', 'post_type' => 'imc_issues', 'author' => $user_id, 'posts_per_page' => -1, 'post__not_in' => $uniqueposts_filters, )); }else{ //first query $pendingOfUser = get_posts(array( 'post_status' => 'pending', 'post_type' => 'imc_issues', 'author' => $user_id, 'posts_per_page' => -1, )); //second query $allPublish = get_posts(array( 'post_status' => 'publish', 'post_type' => 'imc_issues', 'author' => $user_id, 'posts_per_page' => -1, )); } $mergedposts = array_merge($pendingOfUser, $allPublish); //combine queries $postids = array(); foreach ($mergedposts as $item) { $postids[] = $item->ID; //create a new query only of the post ids } $uniqueposts = array_unique($postids); //remove duplicate post ids if(!empty($uniqueposts)) { $custom_query_args = array( 'post_type' => 'imc_issues', 'post_status' => array( 'publish','pending' ), 'post__in' => $uniqueposts, 'paged' => $paged, 'posts_per_page' => $page, ); }else{ $custom_query_args = array( 'post_type' => 'imc_issues', 'post_status' => array( 'publish' ), 'paged' => $paged, 'posts_per_page' => $page, ); } return $custom_query_args; } ?>
- This reply was modified 6 years, 3 months ago by mslave.
Forum: Fixing WordPress
In reply to: is it possible, users to see only their own posts?No i want limit authors to see their own posts on Frontend
Forum: Fixing WordPress
In reply to: is it possible, users to see only their own posts?No,
the first plugin allow user to submit posts from the frontend of your site. (I already have this)
the second plugin is for back-end.Thank you for responding
Forum: Developing with WordPress
In reply to: Its possible to change wp usertableI found this plugin for Drupal. This plugin autocreate the user with same credentials on second database. Its possible to make plugin for wordpress ?
Features
On Drupal Register form create 2 users with same username password and email
First on the Drupal Database and Second on the L2j DatabaseAfter change the drupal user password this plugin auto change the password on l2J database.
<?php /** * @file * Allows users to login on a Drupal website through L2J Server. * * Validate login, profile and register forms. */ /** * Implements hook_help(). * * Retrieve the project help page. */ function l2j_connect_help($path, $arg) { switch ($path) { case 'admin/help#l2j_connect': { return ('<p>' . t('This module allows users to authenticate an external L2jserver System.') . '</p>'); } } } /** * Implements hook_form_FORM_ID_alter(). */ function l2j_connect_form_user_login_block_alter(&$form, $form_state) { return l2j_connect_form_user_login_alter($form, $form_state); } /** * Implements hook_form_FORM_ID_alter(). * * Alter validation for user_login. */ function l2j_connect_form_user_login_alter(&$form, $form_state) { $form['#validate'][] = 'l2j_connect_login_validate'; } /** * Implements hook_form_FORM_ID_alter(). * * Alter validation for user_profile_form. */ function l2j_connect_form_user_profile_form_alter(&$form, $form_state) { $form['#validate'][] = 'l2j_connect_user_profile_form_validate'; } /** * Implements hook_form_FORM_ID_alter(). * * Alter validation for user_register_form. */ function l2j_connect_form_user_register_form_alter(&$form, &$form_state) { $form['#validate'][] = 'l2j_connect_user_register_form_validate'; } /** * Validate the user_register_form submit. */ function l2j_connect_user_register_form_validate($form, &$form_state) { $login = $form_state['values']['name']; $mail = $form_state['values']['mail']; if (empty($form_state['values']['pass'])) { $pass = user_password(); } else { $pass = $form_state['values']['pass']; } if (l2j_connect_login_exists($login)) { form_set_error('name', t('Sorry, the username exists in our L2J Database')); } else if (l2j_connect_mail_exists($mail)) { form_set_error('mail', t('Sorry, the mail exists in our L2J Database')); } else { $details = array( 'login' => $login, 'pass' => $pass, 'mail' => $mail, 'access' => 0, ); $account = (object) $details; l2j_connect_external_create_account($account); } return TRUE; } /** * Validate the user_login form submit. */ function l2j_connect_login_validate($form, &$form_state) { $username = $form_state['values']['name']; $password = $form_state['values']['pass']; // Exists the user in our loginserver? if (!l2j_connect_account_loggin_in($username, $password)) { form_set_error('name', t('There is a problem with your account, please contact an Administrator')); } user_login_authenticate_validate($form, $form_state); } /** * Validate the user_profile_form submit. */ function l2j_connect_user_profile_form_validate($form, &$form_state) { if (l2j_connect_account_exists($form_state['values']['name'], $form_state['values']['mail'])) { $details = array( 'login' => $form_state['values']['name'], 'pass' => $form_state['values']['pass'], 'mail' => $form_state['values']['mail'] ); $account = (object) $details; l2j_connect_external_update_account($account); } else { form_set_error('name', t('There is a problem with your account, please contact an Administrator')); } } /** * Check if a given account exists in L2j loginserver. */ function l2j_connect_login_exists($login) { db_set_active('loginserver'); $result = db_query('SELECT login from {accounts} WHERE login=:login', array(':login' => $login)); $exists = FALSE; foreach ($result as $row) { $exists = TRUE; } db_set_active(); return $exists; } /** * Check if a given email exists in L2j loginserver. */ function l2j_connect_mail_exists($mail) { db_set_active('loginserver'); $result = db_query('SELECT email from {accounts} WHERE email=:mail', array(':mail' => $mail)); $exists = FALSE; foreach ($result as $row) { $exists = TRUE; } db_set_active(); return $exists; } /** * Retrieve the mail info with an account as parameter from L2j loginserver. */ function l2j_connect_retrieve_mail($login) { db_set_active('loginserver'); $result = db_query('SELECT email from {accounts} WHERE login=:login', array(':login' => $login))->fetchField(); db_set_active(); return $result; } /** * Retrieve the login info with an email as parameter from L2j loginserver. */ function l2j_connect_retrieve_login($mail) { db_set_active('loginserver'); $result = db_query('SELECT login from {accounts} WHERE email=:email', array(':email' => $mail))->fetchField(); db_set_active(); return $result; } /** * Check if an L2j account exists in L2j loginserver. */ function l2j_connect_account_exists($login, $email) { db_set_active('loginserver'); $result = db_query('SELECT login, email from {accounts} WHERE login=:login AND email=:email', array(':login' => $login, ':email' => $email)); $exists = FALSE; foreach ($result as $row) { $exists = TRUE; } db_set_active(); return $exists; } /** * Log in L2j loginserver with a given username and password. */ function l2j_connect_account_loggin_in($username, $password) { db_set_active('loginserver'); $result = db_query('SELECT login, password, accessLevel from {accounts} WHERE login=:login AND password=:password AND accessLevel=0', array(':login' => $username, ':password' => l2j_connect_encrypt($password))); $exists = FALSE; foreach ($result as $row) { $exists = TRUE; } db_set_active(); return $exists; } /** * Create an external account in L2j loginserver. */ function l2j_connect_external_create_account($account) { db_set_active('loginserver'); $result = db_insert('accounts') ->fields(array( 'login' => $account->login, 'password' => l2j_connect_encrypt($account->pass), 'email' => $account->mail, 'accessLevel' => $account->access, )) ->execute(); db_set_active(); drupal_set_message(t('The Account has been created in the Loginserver database.'), 'status'); return TRUE; } /** * Update an external account in L2j loginserver. */ function l2j_connect_external_update_account($account) { db_set_active('loginserver'); $fields = array( 'login' => $account->login ); if (!empty($account->pass)) { $fields['password'] = l2j_connect_encrypt($account->pass); } $result = db_update('accounts') ->fields($fields) ->condition('login', $account->login, '=') ->execute(); db_set_active(); return TRUE; } /** * Encrypt a password to match the current L2j loginserver encrypt method. */ function l2j_connect_encrypt($pass) { return base64_encode(pack("H*", sha1(utf8_encode($pass)))); }
This plugin read this from drupal site configuration file
$databases = array ( 'loginserver' => array ( 'default' => array ( 'database' => 'l2jls', 'username' => 'root', 'password' => '', 'host' => 'localhost', 'port' => '', 'driver' => 'mysql', 'prefix' => '', ) ),'gameserver' => array ( 'default' => array ( 'database' => 'l2jgs', 'username' => 'root', 'password' => '', 'host' => 'localhost', 'port' => '', 'driver' => 'mysql', 'prefix' => '', ) ), );
Forum: Developing with WordPress
In reply to: Its possible to change wp usertableAnyone please
Forum: Developing with WordPress
In reply to: Its possible to change wp usertableI want to change the wordpress core to use the l2j server “accounts” table as “wp_users” table
- This reply was modified 7 years, 8 months ago by mslave.
Forum: Developing with WordPress
In reply to: Its possible to change wp usertableI will make a l2j server and i want all wordpress registered users access the game