Skip to main content
added 40 characters in body
Source Link
Tom J Nowell
  • 60.6k
  • 7
  • 77
  • 147

Good Morning... I

I want to make a snippet that when creating a user in a blog add it automatically to another blog (this number 1 always) with the same roll that was created.

For this I am using this:

$ Blog_id = 1; $ User_id = get_current_user_id (); $ Role = 'publisher'; Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

$ Blog_id = 1;
$ User_id = get_current_user_id ();
$ Role = 'publisher';
Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

.....And it does not work,

but if I do this....

$ Blog_id = 1; $ User_id = 127; // 127 is a specific number of a user that already exists $ Role = 'publisher'; Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

$ Blog_id = 1;
$ User_id = 127; // 127 is a specific number of a user that already exists
$ Role = 'publisher';
Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

Then yes that works.

Can someone help me understand why the first (generic) solution does not work with: $ User_id = get_current_user_id (); ?

$ User_id = get_current_user_id (); ?

Good Morning... I want to make a snippet that when creating a user in a blog add it automatically to another blog (this number 1 always) with the same roll that was created.

For this I am using this:

$ Blog_id = 1; $ User_id = get_current_user_id (); $ Role = 'publisher'; Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

.....And it does not work,

but if I do this....

$ Blog_id = 1; $ User_id = 127; // 127 is a specific number of a user that already exists $ Role = 'publisher'; Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

Then yes that works.

Can someone help me understand why the first (generic) solution does not work with: $ User_id = get_current_user_id (); ?

Good Morning...

I want to make a snippet that when creating a user in a blog add it automatically to another blog (this number 1 always) with the same roll that was created.

For this I am using this:

$ Blog_id = 1;
$ User_id = get_current_user_id ();
$ Role = 'publisher';
Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

.....And it does not work,

but if I do this....

$ Blog_id = 1;
$ User_id = 127; // 127 is a specific number of a user that already exists
$ Role = 'publisher';
Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

Then yes that works.

Can someone help me understand why the first (generic) solution does not work with:

$ User_id = get_current_user_id (); ?
Source Link

Adding users to another blog

Good Morning... I want to make a snippet that when creating a user in a blog add it automatically to another blog (this number 1 always) with the same roll that was created.

For this I am using this:

$ Blog_id = 1; $ User_id = get_current_user_id (); $ Role = 'publisher'; Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

.....And it does not work,

but if I do this....

$ Blog_id = 1; $ User_id = 127; // 127 is a specific number of a user that already exists $ Role = 'publisher'; Add_action ('user_register', add_user_to_blog ($ blog_id, $ user_id, $ role));

Then yes that works.

Can someone help me understand why the first (generic) solution does not work with: $ User_id = get_current_user_id (); ?