Jump to content

Addind a new Value to a PageArray Field for a User


beto
 Share

Recommended Posts

I can't add a new value to a custom PageArray field  for my user.

Quote

$current_user = $users->get(3085);
$current_user->setOutputFormatting(false); 
$current_user->galerias->add('2075') ;
$current_user->save();

 

However, when I create a new user, I CAN add the new PageArray value:

Quote

$new_user = new User();
$new_user->name = 'user_2017';
$new_user->galerias->add('2075');
$new_user->save():

 

I need help. Thank you very much.

 

Link to comment
Share on other sites

@kixe: 

Sorry, I mistyped my "quote code". The $existente variable is actually $current_user.

This is my real code/problem:

Quote

$current_user = $users->get(3085);
$current_user->setOutputFormatting(false);
$current_user->galerias->add(2075) ;
$current_user->save();

It does NOT add the page to my "galerias" pagetype field.

Link to comment
Share on other sites

7 hours ago, beto said:

This is my real code/problem:

Quote

$current_user = $users->get(3085);
$current_user->setOutputFormatting(false);
$current_user->galerias->add(2075) ;
$current_user->save();

It does NOT add the page to my "galerias" pagetype field.

It works for me. Double-check your page IDs, field name, and settings of your Page Reference field (allows multiple pages, 'selectable pages' settings allow the page you are trying to add).

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...