Jump to content

blacksrv

Members
  • Posts

    52
  • Joined

  • Last visited

Everything posted by blacksrv

  1. @Adrian & @DaveP, thank you for the time, I'll try to clarify a few things: The error comes from the Social Login plugin that I modify myself, I didn't change that but I already encountered that error in another page that I made and has nothing to do with social login. I'll put the complete code to explain that I already have the $user: $social_id = $provider_name . '-' . $user_profile->identifier; $display_name = $user_profile->displayName; $user = $this->users->get( "social_id=$social_id" ); // Create a random pass to use in login $pass = self::passwordGen(); if ( $user->id ) { $name = $user->name; // User has logged in earlier, change its password $user->of( false ); $user->pass = $pass; $user->save(); } else { if ( property_exists( $user_profile, 'emailVerified' ) ) { $name = $this->sanitizer->pageName( $user_profile->emailVerified ); } else { $name = self::passwordGen(); } // Create the user $user = new User; $user->name = $name; $user->pass = $pass; if ( property_exists( $user_profile, 'email' ) ) { $user->email = $user_profile->email; } $user->social_id = $social_id; $user->oauth = serialize( $user_profile ); $user->addRole( self::socialLoginPagePath ); $user->roles->add( $this->roles->get( "guest" ) ); $user->roles->add( $this->roles->get( "members" ) ); $user->activation_key = "0"; $user->save(); } //$this->session->forceLogin($user); $this->session->login( $name, $pass ); //$this->users->setCurrentUser($user);
  2. Is not a guest user, is a brand new user (or an existing one): $name = $user->name; $user->of( false ); $user->pass = $pass; $user->save(); $this->session->login( $name, $pass );
  3. Hi, I'm having problems with a custom login. I test almost everything I found in the forum: $this->users->setCurrentUser($user); $this->session->forceLogin($user); $this->session->login( $name, $pass ); $this->session->_user_id = $user->id; Nothing works, I always get a failed login for guest. The $user exists, is created I can track the id and everything. Help needed!!!! Thanks
  4. Hi, I'm struggling with a datetime field, I'm using to set a foundation date and when I try to set it to 1803, it doesn't work, in fact, if the date is before 1901-01-01 ít changes to blank. Thanks.
  5. I only have 1 language, the problem I have is that I the translated string are only on the backend.
  6. Hi, I just installed "Languages Support" module to translate a module file. After translating all the files, and changing my default language, I can see the translate strings in the backend, but I can't see it in the frontend. Already tried with a guest user, login/logout, it's not working. Any ideas? Thanks
  7. Hi, it's possible to set the id of a comment?? I'm using: $c = new Comment(); $c->id = $post['id']; but it's not working. I'm importing comments and I need to set the id to add comments replies. Thanks EDIT: Definitely is not working, I tried to create a new comment with id and it's not working. Any ideas?
  8. Stupid Error!! I just move: $page->of(false); $page->setOutputFormatting(false); before foreach ( $fields as $key => $value ) { $page->$key = $value; } Is working now.
  9. Thanks for your help, I just tested with if(!is_object($f->type)) { The same happens.
  10. The same is happening with a filetype, is driving me crazy.
  11. Hi everyone, I'm having a problem with a form I'm creating using the api. The form consist on multiple text fields, one file, and an Options field, everything works fine, except for the options field. The form creates fine, the main problem is on submit. I'm getting this error: Warning: Invalid argument supplied for foreach() in C:\Local\htdocs\wire\modules\Fieldtype\FieldtypeOptions\FieldtypeOptions.module on line 277 I already tried to check the type and use $post_value->id but it's not working. My code: if($input->post->submit_save) { // user submitted the form, process it and check for errors $form->processInput($input->post); $errors = array(); $required_fields = array(); $fields = array(); $post_value = $input->post->{$f->name}; switch ( $f->type ) { case 'text': $the_value = $sanitizer->text( $post_value ); break; case 'textarea': $the_value = $sanitizer->textarea( $post_value ); break; case 'checkbox': $the_value = isset( $post_value ) ? 1 : 0; break; default: $the_value = $post_value; break; } $fields[$f->name] = $the_value; foreach ( $fields as $key => $value ) { $page->$key = $value; } $page->of(false); $page->save(); } Any Ideas? Thanks
  12. Thank you, Now I get it. Something I notice it's important to have Allow URL Segments? checked. Code I'm using if someone is looking for the same: if(count($input->urlSegments) == 1) { $home = false; $seg1 = $sanitizer->pageName($input->urlSegment1); $found = $pages->get("template=articulo-carrera, name=$seg1"); if($found->id) echo $found->render(); }
  13. Exactly like the post quoted: 1) config.php $config->prependTemplateFile = '_init.php'; 2) _init.php require_once("./includes/hooks.php"); 3) hooks.php wire()->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'articulo-carrera') { $event->replace = true; $event->return = "/$page->name/"; } }); Thanks
  14. Hi, following the instructions from this post https://processwire.com/talk/topic/3987-cmscritic-development-case-study/?p=36867. I added a hook to my site to replace the parent URL, when I access to the new url I always get a 404, what I'm missing? hook: wire()->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'articulo-carrera') { $event->replace = true; $event->return = "/$page->name/"; } });
×
×
  • Create New...