Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: Tegyjot Campaign Hug
- */
- if ( !function_exists( 'add_action' ) ) {
- echo "Nana! Csak egy plugin vagyok, ne nyiss meg direktben!";
- exit;
- }
- /*
- function add_hug_role() {
- $role = 'hug';
- $display_name = 'Hug';
- $capabilities = array(
- 'read' => true,
- 'edit_posts' => false,
- 'delete_posts' => false,
- );
- add_role( $role, $display_name, $capabilities );
- }
- add_action('init', 'add_hug_role');
- */
- add_action( 'init', 'campaign_hugvalue_novel' );
- function campaign_hugvalue_novel() {
- if (isset($_POST['hugpost'])) {
- $postid=$_POST['submittedform'];
- $hug=get_field('hug', $postid);
- if (!isset($hugnovelt)) {
- $hugnovelt=0;
- }
- $hugnovelt=$hug+1;
- update_field ('hug', $hugnovelt, $postid);
- $name=get_field('name', $postid);
- $post_ID = wp_insert_post(array(
- 'post_title'=>'Adatgyűjtés - '.$name,
- 'post_name' => nevmask($name)."-".$hugnovelt,
- 'post_type'=>'hugdata',
- 'post_status' => 'publish'));
- $hugdatalink=home_url()."/hugdata/".nevmask($name)."-".$hug;
- wp_redirect($hugdatalink, 301);
- die;
- }
- }
- add_action( 'init', 'campaign_hug_adduser' );
- function campaign_hug_adduser() {
- if (isset($_POST['hugpostform'])) {
- $firstname=$_POST['first'];
- $lastname=$_POST['last'];
- $email=$_POST['email'];
- $namemask=nevmask($firstname." ".$lastname);
- $jelszo=wp_generate_password( 16, false, false );
- if (username_exists($namemask)) {
- $rand=rand(1000, 9999);
- $namedata=$namemask."-".$rand;
- } else {
- $namedata = $namemask;
- }
- $userdatas = array(
- 'user_login' => $namedata,
- 'user_pass' => $jelszo,
- 'first_name' => $firstname,
- 'last_name' => $lastname,
- 'user_email' => $email,
- 'display_name' => $firstname." ".$lastname,
- 'role' => 'hug'
- );
- if ($userdatas['user_email'] !== "[email protected]") {
- $user_id = wp_insert_user( $userdatas ) ;
- wp_redirect(home_url()."/sikeres-oleles/", 302);
- die;
- }
- $file = 'people.txt';
- $current = file_get_contents($file);
- $current .= $firstname;
- file_put_contents($file, $current);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment