Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress Subscriptions in laravel (corcel)

I have 2 projects, one in Wordpress, and the other one in Laravel 4.2.

Recently i had to merge both projects into one Laravel 4.2 App using jgrossi/corcel. This was my only option.

Everything works fantastic! I can even post directly into Wordpress without logging into Wordpress to get posts, comments, etc.

But there is something I can't figure out. Wordpress is using Jetpack for subscribers. The laravel app needs a field to add more subscribers. I have very little experience in Wordpress.

Is it possible to add subscribers from outside Wordpress directly into the database? If not, is there a way to use a Jetpack plugin outside of Wordpress?

like image 403
Ivan Bravo Carlos Avatar asked Jul 17 '15 21:07

Ivan Bravo Carlos


1 Answers

Yes you can add new users in database with subscribers role.

Wordpress stores the users data in wp_users table and its meta info in wp_usermeta. So follow the following steps

  1. Add a new entry in wp_users table. As a sample here is entry from my wp_users table. You can submit values for these attributes using your normal laravel form with post request. enter image description here
  2. Add its related data in wp_usermeta table. Here you need to set two key value attributes against user_id of newly inserted record.
    1. meta_key = wp_capabilites and meta_value = a:1:{s:10:"subscriber";b:1;}. As you can note the meta_value for wp_capabilities is in serialzed form.
    2. meta_key = show_admin_bar_front and meta_value = true.

So you added a new user with subscriber role.

like image 90
hhsadiq Avatar answered Oct 03 '22 08:10

hhsadiq